@@ -57,6 +57,33 @@ bool PotentialBinding::isViableForJoin() const {
57
57
}
58
58
59
59
bool PotentialBindings::isDelayed () const {
60
+ if (auto *locator = TypeVar->getImpl ().getLocator ()) {
61
+ if (locator->isLastElement <LocatorPathElt::MemberRefBase>()) {
62
+ // If first binding is a "fallback" to a protocol type,
63
+ // it means that this type variable should be delayed
64
+ // until it either gains more contextual information, or
65
+ // there are no other type variables to attempt to make
66
+ // forward progress.
67
+ if (Bindings.empty ())
68
+ return true ;
69
+
70
+
71
+ if (Bindings[0 ].BindingType ->is <ProtocolType>())
72
+ return true ;
73
+ }
74
+
75
+ // Since force unwrap preserves l-valueness, resulting
76
+ // type variable has to be delayed until either l-value
77
+ // binding becomes available or there are no other
78
+ // variables to attempt.
79
+ if (locator->directlyAt <ForceValueExpr>() &&
80
+ TypeVar->getImpl ().canBindToLValue ()) {
81
+ return llvm::none_of (Bindings, [](const PotentialBinding &binding) {
82
+ return binding.BindingType ->is <LValueType>();
83
+ });
84
+ }
85
+ }
86
+
60
87
if (isHole ()) {
61
88
auto *locator = TypeVar->getImpl ().getLocator ();
62
89
assert (locator && " a hole without locator?" );
@@ -98,19 +125,6 @@ bool PotentialBindings::isDelayed() const {
98
125
});
99
126
}
100
127
101
- if (auto *locator = TypeVar->getImpl ().getLocator ()) {
102
- // Since force unwrap preserves l-valueness, resulting
103
- // type variable has to be delayed until either l-value
104
- // binding becomes available or there are no other
105
- // variables to attempt.
106
- if (locator->directlyAt <ForceValueExpr>() &&
107
- TypeVar->getImpl ().canBindToLValue ()) {
108
- return llvm::none_of (Bindings, [](const PotentialBinding &binding) {
109
- return binding.BindingType ->is <LValueType>();
110
- });
111
- }
112
- }
113
-
114
128
return !DelayedBy.empty ();
115
129
}
116
130
@@ -440,8 +454,6 @@ void PotentialBindings::finalize(
440
454
addPotentialBinding (
441
455
{protocolTy, AllowedBindingKind::Exact, constraint});
442
456
}
443
-
444
- FullyBound = true ;
445
457
}
446
458
}
447
459
0 commit comments