mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #69304 from xedin/rdar-117220710
[ConstraintSystem] Bring back one-way pattern solving for for-in stat…
This commit is contained in:
@@ -469,6 +469,8 @@ public:
|
||||
bool shouldBindPatternVarsOneWay() const {
|
||||
if (kind == Kind::expression)
|
||||
return expression.bindPatternVarsOneWay;
|
||||
if (kind == Kind::forEachStmt)
|
||||
return !ignoreForEachWhereClause() && forEachStmt.stmt->getWhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -295,3 +295,24 @@ do {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rdar://117220710 - The compiler incorrectly infers `v` pattern to be optional.
|
||||
do {
|
||||
struct S {
|
||||
var test: Int
|
||||
}
|
||||
|
||||
func check(_: S?, _: S?) -> Bool { false }
|
||||
|
||||
func test(data: [S]?, exclusion: S?) {
|
||||
for v in data ?? [] where check(v, exclusion) {
|
||||
_ = v.test // Ok
|
||||
}
|
||||
}
|
||||
|
||||
let _ = { (data: [S]?, exclusion: S?) in
|
||||
for v in data ?? [] where check(v, exclusion) {
|
||||
_ = v.test // Ok
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user