Files
swift-mirror/test/Constraints/issue-79444.swift
Hamish Knight 11a4415ce7 [CS] Fix DeclContext for multi-statement closure captures
Make sure we set the correct DeclContext for CSGen
of multi-statement closure captures, since
otherwise the DeclContext is set to the closure
itself, which is wrong.
2025-02-18 11:30:22 +00:00

21 lines
436 B
Swift

// RUN: %target-typecheck-verify-swift
// https://github.com/swiftlang/swift/issues/79444
class C {
func foo() {
_ = { [x = "\(self)"] in } // expected-warning {{capture 'x' was never used}}
_ = { [x = "\(self)"] in x }
_ = { [x = "\(self)"] in
let y = x
return y
}
_ = { [x = "\(self)"] in
let fn = { [y = "\(x)"] in
let z = y
return z
}
return fn()
}
}
}