mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Restore recently removed logic to mark type variable representing closure parameter used in the body of a closure as potentially incomplete to delay attempting it until `BindParam` is simplified. Resolves: rdar://problem/71858936
29 lines
594 B
Swift
29 lines
594 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
@propertyWrapper
|
|
@dynamicMemberLookup
|
|
struct Binding<Value> {
|
|
var wrappedValue: Value
|
|
|
|
init(get: @escaping () -> Value, set: @escaping (Value) -> Void) {
|
|
self.wrappedValue = get()
|
|
}
|
|
|
|
subscript<Subject>(dynamicMember keyPath: WritableKeyPath<Value, Subject>) -> Binding<Subject> {
|
|
get { fatalError() }
|
|
}
|
|
}
|
|
|
|
class S {
|
|
var value: String = ""
|
|
var buffer: String? = nil
|
|
|
|
var body: String {
|
|
let binding = Binding(
|
|
get: { self.buffer ?? self.value },
|
|
set: { self.buffer = $0 }
|
|
)
|
|
return binding.wrappedValue
|
|
}
|
|
}
|