@@ -57,9 +57,6 @@ bool PotentialBinding::isViableForJoin() const {
57
57
}
58
58
59
59
bool PotentialBindings::isDelayed () const {
60
- if (!DelayedBy.empty ())
61
- return true ;
62
-
63
60
if (isHole ()) {
64
61
auto *locator = TypeVar->getImpl ().getLocator ();
65
62
assert (locator && " a hole without locator?" );
@@ -76,9 +73,32 @@ bool PotentialBindings::isDelayed() const {
76
73
// relies solely on contextual information.
77
74
if (locator->directlyAt <NilLiteralExpr>())
78
75
return true ;
76
+
77
+ // It's possible that type of member couldn't be determined,
78
+ // and if so it would be beneficial to bind member to a hole
79
+ // early to propagate that information down to arguments,
80
+ // result type of a call that references such a member.
81
+ //
82
+ // Note: This is done here instead of during binding inference,
83
+ // because it's possible that variable is marked as a "hole"
84
+ // (or that status is propagated to it) after constraints
85
+ // mentioned below are recorded.
86
+ return llvm::any_of (DelayedBy, [&](Constraint *constraint) {
87
+ switch (constraint->getKind ()) {
88
+ case ConstraintKind::ApplicableFunction:
89
+ case ConstraintKind::DynamicCallableApplicableFunction:
90
+ case ConstraintKind::BindOverload: {
91
+ return !ConstraintSystem::typeVarOccursInType (
92
+ TypeVar, CS.simplifyType (constraint->getSecondType ()));
93
+ }
94
+
95
+ default :
96
+ return true ;
97
+ }
98
+ });
79
99
}
80
100
81
- return false ;
101
+ return !DelayedBy. empty () ;
82
102
}
83
103
84
104
bool PotentialBindings::involvesTypeVariables () const {
@@ -1182,16 +1202,6 @@ void PotentialBindings::infer(Constraint *constraint) {
1182
1202
case ConstraintKind::ApplicableFunction:
1183
1203
case ConstraintKind::DynamicCallableApplicableFunction:
1184
1204
case ConstraintKind::BindOverload: {
1185
- // It's possible that type of member couldn't be determined,
1186
- // and if so it would be beneficial to bind member to a hole
1187
- // early to propagate that information down to arguments,
1188
- // result type of a call that references such a member.
1189
- if (CS.shouldAttemptFixes () && TypeVar->getImpl ().canBindToHole ()) {
1190
- if (ConstraintSystem::typeVarOccursInType (
1191
- TypeVar, CS.simplifyType (constraint->getSecondType ())))
1192
- break ;
1193
- }
1194
-
1195
1205
DelayedBy.push_back (constraint);
1196
1206
break ;
1197
1207
}
0 commit comments