Skip to content

Commit e5d188b

Browse files
committed
[CS] Walk into patterns when looking for closure referenced vars
Previously we would skip over ExprPatterns, but we need to ensure that we walk them, as they may have interesting variable references that the closure needs to be connected to the type variables for. rdar://110617471
1 parent 624f553 commit e5d188b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,10 +2949,6 @@ namespace {
29492949
PreWalkAction walkToDeclPre(Decl *D) override {
29502950
return Action::VisitChildrenIf(isa<PatternBindingDecl>(D));
29512951
}
2952-
2953-
PreWalkResult<Pattern *> walkToPatternPre(Pattern *P) override {
2954-
return Action::SkipChildren(P);
2955-
}
29562952
} collectVarRefs(CS);
29572953

29582954
// Walk the capture list if this closure has one, because it could

test/Constraints/rdar110617471.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// rdar://110617471: Make sure we can type-check this.
4+
class C {
5+
var prop = 0
6+
}
7+
8+
func foo(_ fn: () -> Void) {}
9+
10+
class D {
11+
let c = C()
12+
13+
func bar() {
14+
foo { [c] in
15+
foo {
16+
switch 0 {
17+
case c.prop:
18+
break
19+
default:
20+
break
21+
}
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)