mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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
|
||||
|
||||
25
test/Constraints/rdar110617471.swift
Normal file
25
test/Constraints/rdar110617471.swift
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user