File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -1268,17 +1268,33 @@ ASTBuilder::findDeclContext(NodePointer node) {
1268
1268
return nullptr ;
1269
1269
1270
1270
CanGenericSignature genericSig;
1271
- if (node->getNumChildren () > 2 )
1271
+ bool genericSigMatchesNominal = false ;
1272
+ if (node->getNumChildren () > 2 ) {
1272
1273
genericSig = demangleGenericSignature (nominalDecl, node->getChild (2 ));
1273
1274
1275
+ // If the generic signature are equivalent to that of the nominal type,
1276
+ // we're either in another module or the nominal type is generic and
1277
+ // involves inverse requirements on its generic parameters.
1278
+ genericSigMatchesNominal = genericSig &&
1279
+ genericSig == nominalDecl->getGenericSignatureOfContext ().getCanonicalSignature ();
1280
+
1281
+ // If the generic signature is equivalent to that of the nominal type,
1282
+ // and we're in the same module, it's due to inverse requirements.
1283
+ // Just return the nominal declaration.
1284
+ if (genericSigMatchesNominal &&
1285
+ nominalDecl->getParentModule () == moduleDecl) {
1286
+ return nominalDecl;
1287
+ }
1288
+ }
1289
+
1274
1290
for (auto *ext : nominalDecl->getExtensions ()) {
1275
1291
if (ext->getParentModule () != moduleDecl)
1276
1292
continue ;
1277
1293
1278
1294
if (!ext->isConstrainedExtension ()) {
1279
- if (!genericSig ||
1280
- genericSig->isEqual (nominalDecl->getGenericSignature ()))
1295
+ if (!genericSig || genericSigMatchesNominal)
1281
1296
return ext;
1297
+
1282
1298
continue ;
1283
1299
}
1284
1300
Original file line number Diff line number Diff line change @@ -86,3 +86,16 @@ func useAtomicRepresentation() {
86
86
let x = UnsafePointer< Int> . AtomicRepresentation( )
87
87
print ( x)
88
88
}
89
+
90
+ struct Box < Wrapped: ~ Copyable> : ~ Copyable { }
91
+
92
+ struct List < Element: ~ Copyable> : ~ Copyable {
93
+ // CHECK: $s4test4ListVAARiczrlE4NodeVwst
94
+ struct Node : ~ Copyable {
95
+ var element : Element
96
+ var next : Link
97
+ }
98
+ typealias Link = Box < Node > ?
99
+
100
+ var head : Link
101
+ }
You can’t perform that action at this time.
0 commit comments