Skip to content

Commit 1bd91de

Browse files
committed
Sema: Fix crash with unbound generic types in patterns
1 parent ed33e22 commit 1bd91de

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,12 @@ bool TypeChecker::typeCheckPattern(Pattern *P, DeclContext *dc,
869869
case PatternKind::Typed: {
870870
TypedPattern *TP = cast<TypedPattern>(P);
871871
bool hadError = validateTypedPattern(*this, dc, TP, options, &resolver);
872+
873+
// If we have unbound generic types, don't apply them below; instead,
874+
// the caller will call typeCheckBinding() later.
875+
if (P->getType()->hasUnboundGenericType())
876+
return hadError;
877+
872878
Pattern *subPattern = TP->getSubPattern();
873879
if (coercePatternToType(subPattern, dc, P->getType(),
874880
options|TR_FromNonInferredPattern, &resolver,

validation-test/compiler_crashers/28762-valuetype-hasunboundgenerictype-valuetype-hastypeparameter.swift renamed to validation-test/compiler_crashers_fixed/28762-valuetype-hasunboundgenerictype-valuetype-hastypeparameter.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
guard let f==A:UnfoldSequence

0 commit comments

Comments
 (0)