Files
swift-mirror/test/Constraints/rdar71858936.swift
Pavel Yaskevich 5ebba42268 [ConstraintSystem] Mark type variable representing closure parameter (in the body) as incomplete
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
2020-12-01 20:35:34 -08:00

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