Files
swift-mirror/test/IDE/complete_issue-77305.swift
Hamish Knight 27995eed19 [Completion] Type-check parent closures for local functions
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.
2024-11-11 19:34:21 +00:00

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)
}