File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,25 @@ bool ConstraintSystem::PotentialBindings::isPotentiallyIncomplete() const {
8888 return true ;
8989 }
9090
91+ // If there is a `bind param` constraint associated with
92+ // current type variable, result should be aware of that
93+ // fact. Binding set might be incomplete until
94+ // this constraint is resolved, because we currently don't
95+ // look-through constraints expect to `subtype` to try and
96+ // find related bindings.
97+ // This only affects type variable that appears one the
98+ // right-hand side of the `bind param` constraint and
99+ // represents result type of the closure body, because
100+ // left-hand side gets types from overload choices.
101+ if (llvm::any_of (
102+ EquivalentTo,
103+ [&](const std::pair<TypeVariableType *, Constraint *> &equivalence) {
104+ auto *constraint = equivalence.second ;
105+ return constraint->getKind () == ConstraintKind::BindParam &&
106+ constraint->getSecondType ()->isEqual (TypeVar);
107+ }))
108+ return true ;
109+
91110 return false ;
92111}
93112
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift
2+
3+ @propertyWrapper
4+ @dynamicMemberLookup
5+ struct Binding < Value> {
6+ var wrappedValue : Value
7+
8+ init ( get: @escaping ( ) -> Value , set: @escaping ( Value ) -> Void ) {
9+ self . wrappedValue = get ( )
10+ }
11+
12+ subscript< Subject> ( dynamicMember keyPath: WritableKeyPath < Value , Subject > ) -> Binding < Subject > {
13+ get { fatalError ( ) }
14+ }
15+ }
16+
17+ class S {
18+ var value : String = " "
19+ var buffer : String ? = nil
20+
21+ var body : String {
22+ let binding = Binding (
23+ get: { self . buffer ?? self . value } ,
24+ set: { self . buffer = $0 }
25+ )
26+ return binding. wrappedValue
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments