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) {
12681268 return nullptr ;
12691269
12701270 CanGenericSignature genericSig;
1271- if (node->getNumChildren () > 2 )
1271+ bool genericSigMatchesNominal = false ;
1272+ if (node->getNumChildren () > 2 ) {
12721273 genericSig = demangleGenericSignature (nominalDecl, node->getChild (2 ));
12731274
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+
12741290 for (auto *ext : nominalDecl->getExtensions ()) {
12751291 if (ext->getParentModule () != moduleDecl)
12761292 continue ;
12771293
12781294 if (!ext->isConstrainedExtension ()) {
1279- if (!genericSig ||
1280- genericSig->isEqual (nominalDecl->getGenericSignature ()))
1295+ if (!genericSig || genericSigMatchesNominal)
12811296 return ext;
1297+
12821298 continue ;
12831299 }
12841300
Original file line number Diff line number Diff line change @@ -86,3 +86,16 @@ func useAtomicRepresentation() {
8686 let x = UnsafePointer< Int> . AtomicRepresentation( )
8787 print ( x)
8888}
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