mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Local functions can capture variables from parent closures, so we need to make sure we type-check parent closures when doing completion in a local function. Ideally we ought to be able to be more selective about the elements of the parent closure that we type-check, but that's a more complex change I'm leaving as future work for now.
32 lines
569 B
Swift
32 lines
569 B
Swift
// RUN: %batch-code-completion
|
|
|
|
// https://github.com/swiftlang/swift/issues/77305
|
|
|
|
struct S {
|
|
var x: Int
|
|
}
|
|
|
|
func withFoo(_ x: (S) -> Void) {}
|
|
|
|
withFoo { foo in
|
|
func bar() {
|
|
foo.#^FN_IN_CLOSURE^#
|
|
// FN_IN_CLOSURE: Decl[InstanceVar]/CurrNominal: x[#Int#]; name=x
|
|
}
|
|
}
|
|
|
|
withFoo { x in
|
|
_ = { y in
|
|
func bar() {
|
|
_ = { z in
|
|
func baz() {
|
|
func qux() {
|
|
z.#^VERY_NESTED_FN_IN_CLOSURE^#
|
|
// VERY_NESTED_FN_IN_CLOSURE: Decl[InstanceVar]/CurrNominal: x[#Int#]; name=x
|
|
}
|
|
}
|
|
}(y)
|
|
}
|
|
}(x)
|
|
}
|