[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
This commit is contained in:
Hamish Knight
2023-06-12 18:27:24 +01:00
parent dcb3b9b890
commit 1616e167b9
2 changed files with 25 additions and 4 deletions

View File

@@ -2949,10 +2949,6 @@ namespace {
PreWalkAction walkToDeclPre(Decl *D) override {
return Action::VisitChildrenIf(isa<PatternBindingDecl>(D));
}
PreWalkResult<Pattern *> walkToPatternPre(Pattern *P) override {
return Action::SkipChildren(P);
}
} collectVarRefs(CS);
// Walk the capture list if this closure has one, because it could

View File

@@ -0,0 +1,25 @@
// RUN: %target-typecheck-verify-swift
// rdar://110617471: Make sure we can type-check this.
class C {
var prop = 0
}
func foo(_ fn: () -> Void) {}
class D {
let c = C()
func bar() {
foo { [c] in
foo {
switch 0 {
case c.prop:
break
default:
break
}
}
}
}
}