File tree Expand file tree Collapse file tree 6 files changed +42
-0
lines changed Expand file tree Collapse file tree 6 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ class ASTBuilder {
104
104
105
105
ProtocolDecl *createObjCProtocolDecl (StringRef name);
106
106
107
+ Type createDynamicSelfType (Type selfType);
108
+
107
109
Type createForeignClassType (StringRef mangledName);
108
110
109
111
Type getUnnamedForeignClassType ();
Original file line number Diff line number Diff line change @@ -288,7 +288,16 @@ class TypeDecoder {
288
288
289
289
return BuiltType ();
290
290
}
291
+ case NodeKind::DynamicSelf: {
292
+ if (Node->getNumChildren () != 1 )
293
+ return BuiltType ();
294
+
295
+ auto selfType = decodeMangledType (Node->getChild (0 ));
296
+ if (!selfType)
297
+ return BuiltType ();
291
298
299
+ return Builder.createDynamicSelfType (selfType);
300
+ }
292
301
case NodeKind::DependentGenericParamType: {
293
302
auto depth = Node->getChild (0 )->getIndex ();
294
303
auto index = Node->getChild (1 )->getIndex ();
Original file line number Diff line number Diff line change @@ -329,6 +329,11 @@ class TypeRefBuilder {
329
329
return SILBoxTypeRef::create (*this , base);
330
330
}
331
331
332
+ const TypeRef *createDynamicSelfType (const TypeRef *selfType) {
333
+ // TypeRefs should not contain DynamicSelfType.
334
+ return nullptr ;
335
+ }
336
+
332
337
const ObjCClassTypeRef *getUnnamedObjCClassType () {
333
338
return createObjCClassType (" " );
334
339
}
Original file line number Diff line number Diff line change @@ -316,6 +316,10 @@ ProtocolDecl *ASTBuilder::createObjCProtocolDecl(StringRef name) {
316
316
return nullptr ;
317
317
}
318
318
319
+ Type ASTBuilder::createDynamicSelfType (Type selfType) {
320
+ return DynamicSelfType::get (selfType, Ctx);
321
+ }
322
+
319
323
Type ASTBuilder::createForeignClassType (StringRef mangledName) {
320
324
auto typeDecl = createNominalTypeDecl (mangledName);
321
325
if (!typeDecl) return Type ();
Original file line number Diff line number Diff line change @@ -1120,6 +1120,11 @@ class DecodedMetadataBuilder {
1120
1120
protocols.size (), protocols.data ());
1121
1121
}
1122
1122
1123
+ BuiltType createDynamicSelfType (BuiltType selfType) const {
1124
+ // Free-standing mangled type strings should not contain DynamicSelfType.
1125
+ return BuiltType ();
1126
+ }
1127
+
1123
1128
BuiltType createGenericTypeParameterType (unsigned depth,
1124
1129
unsigned index) const {
1125
1130
// Use the callback, when provided.
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+
3
+ // RUN: %target-build-swift -emit-executable %s -g -o %t/dynamic_self -emit-module
4
+ // RUN: sed -ne '/\/\/ *DEMANGLE: /s/\/\/ *DEMANGLE: *//p' < %s > %t/input
5
+ // RUN: %lldb-moduleimport-test %t/dynamic_self -type-from-mangled=%t/input | %FileCheck %s
6
+
7
+ class Me {
8
+ func mine( ) -> Self {
9
+ let metatype = type ( of: self )
10
+ return metatype. init ( )
11
+ }
12
+
13
+ required init ( ) { }
14
+ }
15
+
16
+ // DEMANGLE: $s12dynamic_self2MeCXDXMTD
17
+ // CHECK: Self.Type
You can’t perform that action at this time.
0 commit comments