Skip to content

Commit 729a69e

Browse files
committed
AST: Assert if ASTContext::getOpenedArchetypeSignature() is called with an interface type
For a class-constrained existential type 'P & C', the opened existential signature is <Self where Self : P, Self : C>. If the class type is generic, like 'P & C<T>', then this also works if T is an archetype, because we get <Self where Self : P, Self : C<T>> and 'T' is an archetype from the outer generic environment. However if T is an interface type, we end up building an invalid signature because the opened existential signature does not have the generic parameter for T. Instead of crashing deeper in the Requirement Machine, guard against this case with an assert in getOpenedArchetypeSignature().
1 parent ba855ae commit 729a69e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5177,6 +5177,7 @@ CanGenericSignature ASTContext::getOpenedArchetypeSignature(Type type) {
51775177
type = existential->getConstraintType();
51785178

51795179
const CanType constraint = type->getCanonicalType();
5180+
assert(!constraint->hasTypeParameter() && "This only works with archetypes");
51805181

51815182
// The opened archetype signature for a protocol type is identical
51825183
// to the protocol's own canonical generic signature.

0 commit comments

Comments
 (0)