@@ -6159,12 +6159,7 @@ bool ConstraintSystem::repairFailures(
61596159 // unrelated fixes, let's proactively bind all of the pattern
61606160 // elemnts to holes here.
61616161 if (lhs->isAny()) {
6162- rhs.visit([&](Type type) {
6163- if (auto *typeVar = type->getAs<TypeVariableType>()) {
6164- assignFixedType(typeVar,
6165- PlaceholderType::get(getASTContext(), typeVar));
6166- }
6167- });
6162+ recordTypeVariablesAsHoles(rhs);
61686163 }
61696164
61706165 conversionsOrFixes.push_back(CollectionElementContextualMismatch::create(
@@ -10402,8 +10397,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
1040210397 // equality instead of argument application constraint, so allowing
1040310398 // them to bind member could mean missing valid hole positions in
1040410399 // the pattern.
10405- assignFixedType(memberTypeVar, PlaceholderType::get(getASTContext(),
10406- memberTypeVar));
10400+ recordTypeVariablesAsHoles(memberTypeVar);
1040710401 } else {
1040810402 recordPotentialHole(memberTypeVar);
1040910403 }
@@ -14008,8 +14002,24 @@ void ConstraintSystem::recordAnyTypeVarAsPotentialHole(Type type) {
1400814002 return;
1400914003
1401014004 type.visit([&](Type type) {
14011- if (auto *typeVar = type->getAs<TypeVariableType>())
14005+ if (auto *typeVar = type->getAs<TypeVariableType>()) {
1401214006 typeVar->getImpl().enableCanBindToHole(getSavedBindings());
14007+ }
14008+ });
14009+ }
14010+
14011+ void ConstraintSystem::recordTypeVariablesAsHoles(Type type) {
14012+ type.visit([&](Type componentTy) {
14013+ if (auto *typeVar = componentTy->getAs<TypeVariableType>()) {
14014+ // Ignore bound type variables. This can happen if a type variable
14015+ // occurs in multiple positions and/or if type hasn't been fully
14016+ // simplified before this call.
14017+ if (typeVar->getImpl().hasRepresentativeOrFixed())
14018+ return;
14019+
14020+ assignFixedType(typeVar,
14021+ PlaceholderType::get(getASTContext(), typeVar));
14022+ }
1401314023 });
1401414024}
1401514025
0 commit comments