Skip to content

Commit b081bdb

Browse files
committed
[CSGen] Allow is pattern types to be holes
1 parent 70eeccb commit b081bdb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,8 +2768,9 @@ namespace {
27682768
// correct handling of patterns like `_ as Foo` where `_` would
27692769
// get a type of `Foo` but `is` pattern enclosing it could still be
27702770
// inferred from enclosing context.
2771-
auto isType = CS.createTypeVariable(CS.getConstraintLocator(pattern),
2772-
TVO_CanBindToNoEscape);
2771+
auto isType =
2772+
CS.createTypeVariable(CS.getConstraintLocator(pattern),
2773+
TVO_CanBindToNoEscape | TVO_CanBindToHole);
27732774
CS.addConstraint(
27742775
ConstraintKind::Conversion, subPatternType, isType,
27752776
locator.withPathElement(LocatorPathElt::PatternMatch(pattern)));
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
var a: Any?
4+
5+
let _: () -> Void = {
6+
for case (is Int)? in [a] {}
7+
if case (is Int, is Int) = a {} // expected-error {{cannot convert value of type 'Any?' to specified type '(_, _)'}}
8+
}

0 commit comments

Comments
 (0)