Skip to content

Commit 8fab074

Browse files
committed
AST: Fix regression from SubstFlags::UseErrorTypes removal
Note that while the original crasher in the radar is gone, my reduced test case triggers an IRGen crash on both 5.1 and master because of an unrelated bug that appears to be related to protocol requirement signatures and declaration ordering. Fixes <rdar://problem/54952911>.
1 parent 059b0c8 commit 8fab074

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

lib/AST/SubstitutionMap.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,15 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
388388
if (conformance->isAbstract()) {
389389
// FIXME: Rip this out once we can get a concrete conformance from
390390
// an archetype.
391-
auto *M = proto->getParentModule();
392391
auto substType = type.subst(*this);
392+
if (substType->hasError())
393+
return ProtocolConformanceRef(proto);
394+
393395
if ((!substType->is<ArchetypeType>() ||
394396
substType->castTo<ArchetypeType>()->getSuperclass()) &&
395397
!substType->isTypeParameter() &&
396398
!substType->isExistentialType()) {
399+
auto *M = proto->getParentModule();
397400
return M->lookupConformance(substType, proto);
398401
}
399402

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s
2+
// FIXME: Get the above to pass with -emit-ir too.
3+
4+
public protocol P1 {
5+
associatedtype A1: P3 where A1.A4.A3: P6
6+
}
7+
8+
public protocol P12 : P1 where A1: P2 {}
9+
10+
public protocol P2 : P3 where A3 == S3<A2>, A4: P4 {}
11+
12+
public protocol P4 : P3 where A3 == S2<A2>, A4: P5 {}
13+
14+
public protocol P5: P9 where A3 == S1<A2> {}
15+
16+
public protocol P6: P11 where A2: P7 {}
17+
18+
public protocol P7: P8 {}
19+
20+
public protocol P8 {}
21+
22+
public protocol P11 {
23+
associatedtype A2 : P8
24+
}
25+
26+
public struct S1<A2 : P8> : P11 {}
27+
28+
public struct S2<A2 : P8> : P11 {}
29+
30+
extension S2: P6 where A2: P7 {}
31+
32+
public struct S3<A2 : P8> : P11 {}
33+
34+
public protocol P9 {
35+
associatedtype A2: P7
36+
associatedtype A3: P11 where A3.A2 == A2
37+
}
38+
39+
public protocol P3 : P9 {
40+
associatedtype A4: P9 where A4.A2 == A2
41+
}
42+
43+
public protocol P10 {
44+
associatedtype A3: P11 where A3.A2: P7
45+
}
46+
47+
public struct S4<T: P12> : P10 {
48+
public typealias A3 = T.A1.A4.A3
49+
}

0 commit comments

Comments
 (0)