Skip to content

Commit f18293b

Browse files
committed
[CS] Walk ExprPattern conjunction elements when finding type variables
Apply the same logic that we apply to other conjunction elements, to make sure that e.g property wrapper projected values work correctly. rdar://110649179
1 parent 1616e16 commit f18293b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

lib/Sema/CSSyntacticElement.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2625,8 +2625,10 @@ void ConjunctionElement::findReferencedVariables(
26252625
}
26262626

26272627
if (element.is<Decl *>() || element.is<StmtConditionElement *>() ||
2628-
element.is<Expr *>() || element.isStmt(StmtKind::Return))
2628+
element.is<Expr *>() || element.isPattern(PatternKind::Expr) ||
2629+
element.isStmt(StmtKind::Return)) {
26292630
element.walk(refFinder);
2631+
}
26302632
}
26312633

26322634
Type constraints::isPlaceholderVar(PatternBindingDecl *PB) {

test/Constraints/issue-66561.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// https://github.com/apple/swift/issues/66561
4+
5+
@propertyWrapper
6+
struct WrapperValue<Value> {
7+
var value: Value
8+
init(wrappedValue: Value) {
9+
self.value = wrappedValue
10+
}
11+
12+
var projectedValue: Self {
13+
return self
14+
}
15+
16+
var wrappedValue: Value {
17+
get {
18+
self.value
19+
}
20+
set {
21+
self.value = newValue
22+
}
23+
}
24+
}
25+
26+
func test() {
27+
let _ = {
28+
@WrapperValue var value: Bool = false
29+
switch value {
30+
case $value.wrappedValue:
31+
break
32+
default:
33+
break
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)