Skip to content

Commit 86e5ed1

Browse files
committed
Add a bailout path to protocol requirement source formation
The GSB will try to form and note invalid constraints, but there are a few paths that aren't prepared for error types to pop up. Add a defensive check to formProtocolRelativeType to make sure we don't wind up force-casting an error type. Fixes rdar://56116278
1 parent 54e94b5 commit 86e5ed1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,10 @@ void RequirementSource::print(llvm::raw_ostream &out,
14421442
static Type formProtocolRelativeType(ProtocolDecl *proto,
14431443
Type baseType,
14441444
Type type) {
1445+
// Error case: hand back the erroneous type.
1446+
if (type->hasError())
1447+
return type;
1448+
14451449
// Basis case: we've hit the base potential archetype.
14461450
if (baseType->isEqual(type))
14471451
return proto->getSelfInterfaceType();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: not %target-typecheck-verify-swift
2+
3+
protocol P where A : Int {}

0 commit comments

Comments
 (0)