Skip to content

Commit b10d97d

Browse files
authored
Merge pull request swiftlang#72433 from DougGregor/demangle-noncopyable-ext
[Demangle-to-type] Properly match extensions of conditionally-copyable types
2 parents 992396b + 942eb62 commit b10d97d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,9 +1282,20 @@ ASTBuilder::findDeclContext(NodePointer node) {
12821282
continue;
12831283
}
12841284

1285-
if (ext->getGenericSignature().getCanonicalSignature() == genericSig) {
1285+
auto extSig = ext->getGenericSignature().getCanonicalSignature();
1286+
if (extSig == genericSig) {
12861287
return ext;
12871288
}
1289+
1290+
// If the extension mangling doesn't include a generic signature, it
1291+
// might be because the nominal type suppresses conformance.
1292+
if (!genericSig) {
1293+
SmallVector<Requirement, 2> requirements;
1294+
SmallVector<InverseRequirement, 2> inverses;
1295+
extSig->getRequirementsWithInverses(requirements, inverses);
1296+
if (requirements.empty())
1297+
return ext;
1298+
}
12881299
}
12891300

12901301
return nullptr;

test/IRGen/mangling_inverse_generics_evolution.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ open class ManagedBuffer<Header, Element: ~Copyable> {
7676
fatalError("boom")
7777
}
7878
}
79+
80+
extension UnsafePointer {
81+
struct AtomicRepresentation { }
82+
}
83+
84+
// CHECK: $sSP4testE20AtomicRepresentationVySi_GD
85+
func useAtomicRepresentation() {
86+
let x = UnsafePointer<Int>.AtomicRepresentation()
87+
print(x)
88+
}

0 commit comments

Comments
 (0)