Skip to content

Commit 7543d4d

Browse files
committed
IRGen: Deal with broken conformance in the AST
rdar://57876556
1 parent f00cf8a commit 7543d4d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,11 @@ static bool isDependentConformance(
913913

914914
auto assocConformance =
915915
conformance->getAssociatedConformance(req.getFirstType(), assocProtocol);
916+
917+
// We migh be presented with a broken AST.
918+
if (assocConformance.isInvalid())
919+
return false;
920+
916921
if (assocConformance.isAbstract() ||
917922
isDependentConformance(IGM,
918923
assocConformance.getConcrete()

test/IRGen/Inputs/batchmode_errors.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ class SomeClass {
1212
var x : AnotherClass2? = nil
1313
}
1414

15+
protocol P {}
16+
protocol WithAssoc {
17+
associatedtype AssocType : P
18+
}
19+
20+
struct BuggyConformer : WithAssoc {
21+
typealias AssocType = Int
22+
}

test/IRGen/batchmode_ast_errors.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@
99
extension SomeClass : SomeProto {
1010
func conform() {}
1111
}
12+
13+
func genericParam<T: WithAssoc>(_ t: T) {
14+
}
15+
16+
func testBuggyGenericParam() {
17+
genericParam(BuggyConformer())
18+
}

0 commit comments

Comments
 (0)