Skip to content

Commit 0dafe2d

Browse files
committed
Swift: Mangle ArchetypeTypes with different superclasses in different extensions.
1 parent 3e7a7fe commit 0dafe2d

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

swift/extractor/mangler/SwiftMangler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ SwiftMangledName SwiftMangler::visitTypeAliasType(const swift::TypeAliasType* ty
308308

309309
SwiftMangledName SwiftMangler::visitArchetypeType(const swift::ArchetypeType* type) {
310310
auto ret = initMangled(type) << fetch(type->getInterfaceType());
311+
if (const auto super = type->getSuperclass()) {
312+
ret << ':' << fetch(super);
313+
}
311314
for (const auto* protocol : type->getConformsTo()) {
312315
// Including the protocols in the mangled name allows us to distinguish the "same" type in
313316
// different extensions, where it might have different constraints. Mangling the context (i.e.

swift/ql/test/extractor-tests/generated/type/PrimaryArchetypeType/PrimaryArchetypeType.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
| Base | getName: | Base | getCanonicalType: | Base | getInterfaceType: | Base | hasSuperclass: | no | getNumberOfProtocols: | 1 |
22
| Base | getName: | Base | getCanonicalType: | Base | getInterfaceType: | Base | hasSuperclass: | no | getNumberOfProtocols: | 1 |
3+
| Base | getName: | Base | getCanonicalType: | Base | getInterfaceType: | Base | hasSuperclass: | yes | getNumberOfProtocols: | 0 |
4+
| Base | getName: | Base | getCanonicalType: | Base | getInterfaceType: | Base | hasSuperclass: | yes | getNumberOfProtocols: | 0 |
35
| Param | getName: | Param | getCanonicalType: | Param | getInterfaceType: | Param | hasSuperclass: | no | getNumberOfProtocols: | 0 |
46
| ParamWithProtocols | getName: | ParamWithProtocols | getCanonicalType: | ParamWithProtocols | getInterfaceType: | ParamWithProtocols | hasSuperclass: | no | getNumberOfProtocols: | 2 |
57
| ParamWithSuperclass | getName: | ParamWithSuperclass | getCanonicalType: | ParamWithSuperclass | getInterfaceType: | ParamWithSuperclass | hasSuperclass: | yes | getNumberOfProtocols: | 0 |
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| Base | 0 | primary_archetypes.swift:3:1:3:13 | P |
2-
| Base | 0 | primary_archetypes.swift:4:1:4:14 | P2 |
1+
| Base | 0 | primary_archetypes.swift:4:1:4:13 | P |
2+
| Base | 0 | primary_archetypes.swift:5:1:5:14 | P2 |
33
| ParamWithProtocols | 0 | file://:0:0:0:0 | Equatable |
4-
| ParamWithProtocols | 1 | primary_archetypes.swift:3:1:3:13 | P |
4+
| ParamWithProtocols | 1 | primary_archetypes.swift:4:1:4:13 | P |
55
| ParamWithSuperclassAndProtocols | 0 | file://:0:0:0:0 | Equatable |
6-
| ParamWithSuperclassAndProtocols | 1 | primary_archetypes.swift:3:1:3:13 | P |
6+
| ParamWithSuperclassAndProtocols | 1 | primary_archetypes.swift:4:1:4:13 | P |
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
| Base | S |
2+
| Base | S2 |
13
| ParamWithSuperclass | S |
24
| ParamWithSuperclassAndProtocols | S |

swift/ql/test/extractor-tests/generated/type/PrimaryArchetypeType/primary_archetypes.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class S {}
2+
class S2 {}
23

34
protocol P {}
45
protocol P2 {}
@@ -13,7 +14,12 @@ class Generic<Base> {}
1314
extension Generic where Base : P {
1415
func f(_: Base) {}
1516
}
16-
1717
extension Generic where Base : P2 {
1818
func f(_: Base) {}
1919
}
20+
extension Generic where Base : S {
21+
func f(_: Base) {}
22+
}
23+
extension Generic where Base : S2 {
24+
func f(_: Base) {}
25+
}

0 commit comments

Comments
 (0)