Skip to content

Commit 6bc2082

Browse files
committed
ASTDemangler: Remove overly-zealous validation check when demangling constrained existential types
1 parent dfcc4fc commit 6bc2082

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ Type ASTBuilder::createConstrainedExistentialType(
674674

675675
case RequirementKind::SameType:
676676
if (auto *DMT = req.getFirstType()->getAs<DependentMemberType>())
677-
if (baseDecl->getAssociatedType(DMT->getName()))
678-
cmap[DMT->getName()] = req.getSecondType();
677+
cmap[DMT->getName()] = req.getSecondType();
679678
}
680679
}
681680
llvm::SmallVector<Type, 4> args;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-build-swift -emit-executable %s -g -o %t/constrained_existentials -emit-module -Xfrontend -disable-availability-checking
4+
// RUN: sed -ne '/\/\/ *DEMANGLE: /s/\/\/ *DEMANGLE: *//p' < %s > %t/input
5+
// RUN: %lldb-moduleimport-test %t/constrained_existentials -type-from-mangled=%t/input | %FileCheck %s
6+
7+
func blackHole(_: Any...) {}
8+
9+
protocol BaseProto<A, B> {
10+
associatedtype A
11+
associatedtype B
12+
}
13+
14+
protocol DerivedProto<A, B>: BaseProto {}
15+
16+
protocol OtherProto {}
17+
18+
struct S<A, B>: DerivedProto, OtherProto {}
19+
20+
// We should lift the artificial ban on compositions involving constrained protocol types
21+
typealias BaseProtoIntStringAndOtherProto = BaseProto<Int, String> & OtherProto
22+
23+
do {
24+
let e0: any BaseProto<Int, String> = S<Int, String>()
25+
let e1: any BaseProto<Int, String>.Type = S<Int, String>.self
26+
let e2: (any BaseProto<Int, String>).Type = (any BaseProto<Int, String>).self
27+
28+
blackHole(e0, e1, e2)
29+
}
30+
31+
// DEMANGLE: $s24constrained_existentials9BaseProto_pSi1AAaBPRts_SS1BADRtsXPD
32+
// DEMANGLE: $s24constrained_existentials9BaseProto_pSi1AAaBPRts_SS1BADRtsXPXmTD
33+
// DEMANGLE: $s24constrained_existentials9BaseProto_pSi1AAaBPRts_SS1BADRtsXPXMtD
34+
35+
// CHECK: BaseProto<Int, String>
36+
// CHECK: @thick BaseProto<Int, String>.Type
37+
// CHECK: @thin BaseProto<Int, String>.Protocol
38+
39+
do {
40+
let e0: any DerivedProto<Int, String> = S<Int, String>()
41+
let e1: any DerivedProto<Int, String>.Type = S<Int, String>.self
42+
let e2: (any DerivedProto<Int, String>).Type = (any DerivedProto<Int, String>).self
43+
44+
blackHole(e0, e1, e2)
45+
}

0 commit comments

Comments
 (0)