Skip to content

Commit c7c9510

Browse files
committed
[ConstraintSystem] Don't re-attempt to bind type variable if it could be a hole
If type variable is allowed to be a hole and it can't be bound to this particular (full resolved) type, just ignore this binding instead of re-trying it later.
1 parent 423bcdf commit c7c9510

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,8 +2249,17 @@ ConstraintSystem::matchTypesBindTypeVar(
22492249
// Simplify the right-hand type and perform the "occurs" check.
22502250
typeVar = getRepresentative(typeVar);
22512251
type = simplifyType(type, flags);
2252-
if (!isBindable(typeVar, type))
2252+
if (!isBindable(typeVar, type)) {
2253+
if (shouldAttemptFixes()) {
2254+
// If type variable is allowed to be a hole and it can't be bound to
2255+
// a particular (full resolved) type, just ignore this binding
2256+
// instead of re-trying it and failing later.
2257+
if (typeVar->getImpl().canBindToHole() && !type->hasTypeVariable())
2258+
return getTypeMatchSuccess();
2259+
}
2260+
22532261
return formUnsolvedResult();
2262+
}
22542263

22552264
// Since member lookup doesn't check requirements
22562265
// it might sometimes return types which are not

0 commit comments

Comments
 (0)