28
28
namespace swift {
29
29
namespace Demangle {
30
30
31
+ enum class ImplMetatypeRepresentation {
32
+ Thin,
33
+ Thick,
34
+ ObjC,
35
+ };
36
+
31
37
// / Describe a function parameter, parameterized on the type
32
38
// / representation.
33
39
template <typename BuiltType>
@@ -243,18 +249,22 @@ class TypeDecoder {
243
249
case NodeKind::Metatype:
244
250
case NodeKind::ExistentialMetatype: {
245
251
unsigned i = 0 ;
246
- bool wasAbstract = false ;
252
+ Optional<ImplMetatypeRepresentation> repr ;
247
253
248
254
// Handle lowered metatypes in a hackish way. If the representation
249
255
// was not thin, force the resulting typeref to have a non-empty
250
256
// representation.
251
257
if (Node->getNumChildren () >= 2 ) {
252
- auto repr = Node->getChild (i++);
253
- if (repr ->getKind () != NodeKind::MetatypeRepresentation ||
254
- !repr ->hasText ())
258
+ auto reprNode = Node->getChild (i++);
259
+ if (reprNode ->getKind () != NodeKind::MetatypeRepresentation ||
260
+ !reprNode ->hasText ())
255
261
return BuiltType ();
256
- if (repr->getText () != " @thin" )
257
- wasAbstract = true ;
262
+ if (reprNode->getText () == " @thin" )
263
+ repr = ImplMetatypeRepresentation::Thin;
264
+ else if (reprNode->getText () == " @thick" )
265
+ repr = ImplMetatypeRepresentation::Thick;
266
+ else if (reprNode->getText () == " @objc_metatype" )
267
+ repr = ImplMetatypeRepresentation::ObjC;
258
268
} else if (Node->getNumChildren () < 1 ) {
259
269
return BuiltType ();
260
270
}
@@ -263,11 +273,9 @@ class TypeDecoder {
263
273
if (!instance)
264
274
return BuiltType ();
265
275
if (Node->getKind () == NodeKind::Metatype) {
266
- return Builder.createMetatypeType (instance, wasAbstract );
276
+ return Builder.createMetatypeType (instance, repr );
267
277
} else if (Node->getKind () == NodeKind::ExistentialMetatype) {
268
- // FIXME: Ignore representation of existential metatype
269
- // completely for now
270
- return Builder.createExistentialMetatypeType (instance);
278
+ return Builder.createExistentialMetatypeType (instance, repr);
271
279
} else {
272
280
assert (false );
273
281
return nullptr ;
0 commit comments