Skip to content

Commit 883d583

Browse files
[CSSimplify] Make sure visit and record holes recursivelly for dependent member type
1 parent 23605e1 commit 883d583

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3158,8 +3158,7 @@ class ConstraintSystem {
31583158
/// subsequent solution would be worse than the best known solution.
31593159
bool recordFix(ConstraintFix *fix, unsigned impact = 1);
31603160

3161-
void recordPotentialHole(TypeVariableType *typeVar);
3162-
void recordPotentialHole(FunctionType *fnType);
3161+
void recordPotentialHole(Type type);
31633162

31643163
void recordTrailingClosureMatch(
31653164
ConstraintLocator *locator,

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9913,16 +9913,11 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix, unsigned impact) {
99139913
return false;
99149914
}
99159915

9916-
void ConstraintSystem::recordPotentialHole(TypeVariableType *typeVar) {
9917-
assert(typeVar);
9918-
typeVar->getImpl().enableCanBindToHole(getSavedBindings());
9919-
}
9920-
9921-
void ConstraintSystem::recordPotentialHole(FunctionType *fnType) {
9922-
assert(fnType);
9923-
Type(fnType).visit([&](Type type) {
9916+
void ConstraintSystem::recordPotentialHole(Type type) {
9917+
assert(type->hasTypeVariable());
9918+
type.visit([&](Type type) {
99249919
if (auto *typeVar = type->getAs<TypeVariableType>())
9925-
recordPotentialHole(typeVar);
9920+
typeVar->getImpl().enableCanBindToHole(getSavedBindings());
99269921
});
99279922
}
99289923

@@ -10024,7 +10019,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
1002410019
newTupleTypes.push_back(smallerElt);
1002510020
} else {
1002610021
if (largerElt.getType()->isTypeVariableOrMember())
10027-
recordPotentialHole(largerElt.getType()->getAs<TypeVariableType>());
10022+
recordPotentialHole(largerElt.getType());
1002810023
}
1002910024
}
1003010025
auto matchingType =

0 commit comments

Comments
 (0)