Skip to content

Commit 0099713

Browse files
committed
Sema: Fix crash with associated type <=> typealias circularity
1 parent 8c9edae commit 0099713

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,13 @@ LookupTypeResult TypeChecker::lookupMemberType(DeclContext *dc,
459459
// Use the type witness.
460460
auto concrete = conformance->getConcrete();
461461
Type memberType = concrete->getTypeWitness(assocType, this);
462+
463+
// This is the only case where NormalProtocolConformance::
464+
// getTypeWitnessAndDecl() returns a null type.
465+
if (concrete->getState() ==
466+
ProtocolConformanceState::CheckingTypeWitnesses)
467+
continue;
468+
462469
assert(memberType && "Missing type witness?");
463470

464471
// If we haven't seen this type result yet, add it to the result set.

validation-test/compiler_crashers/28751-membertype-missing-type-witness.swift renamed to validation-test/compiler_crashers_fixed/28751-membertype-missing-type-witness.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

88
// REQUIRES: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
9+
// RUN: not %target-swift-frontend %s -emit-ir
1010
{class a:P{{}typealias a:Self.a}protocol P{typealias a

0 commit comments

Comments
 (0)