From c7c95103663543081a1aafebc937dba766b5a59c Mon Sep 17 00:00:00 2001 From: Pavel Yaskevich Date: Fri, 24 Jan 2020 17:07:43 -0800 Subject: [PATCH] [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. --- lib/Sema/CSSimplify.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 4568823340f..2794e9650a1 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -2249,8 +2249,17 @@ ConstraintSystem::matchTypesBindTypeVar( // Simplify the right-hand type and perform the "occurs" check. typeVar = getRepresentative(typeVar); 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(); + } // Since member lookup doesn't check requirements // it might sometimes return types which are not