mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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.
This commit is contained in:
committed by
Pavel Yaskevich
parent
423bcdfcdd
commit
c7c9510366
@@ -2249,8 +2249,17 @@ ConstraintSystem::matchTypesBindTypeVar(
|
|||||||
// Simplify the right-hand type and perform the "occurs" check.
|
// Simplify the right-hand type and perform the "occurs" check.
|
||||||
typeVar = getRepresentative(typeVar);
|
typeVar = getRepresentative(typeVar);
|
||||||
type = simplifyType(type, flags);
|
type = simplifyType(type, flags);
|
||||||
if (!isBindable(typeVar, type))
|
if (!isBindable(typeVar, type)) {
|
||||||
|
if (shouldAttemptFixes()) {
|
||||||
|
// If type variable is allowed to be a hole and it can't be bound to
|
||||||
|
// a particular (full resolved) type, just ignore this binding
|
||||||
|
// instead of re-trying it and failing later.
|
||||||
|
if (typeVar->getImpl().canBindToHole() && !type->hasTypeVariable())
|
||||||
|
return getTypeMatchSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
return formUnsolvedResult();
|
return formUnsolvedResult();
|
||||||
|
}
|
||||||
|
|
||||||
// Since member lookup doesn't check requirements
|
// Since member lookup doesn't check requirements
|
||||||
// it might sometimes return types which are not
|
// it might sometimes return types which are not
|
||||||
|
|||||||
Reference in New Issue
Block a user