[CSSimplify] Adjust replaceTypeVariablesWithFreshPacks to propagate holes

If type variable that is being replaces allowed holes, the new one
should not lose this property.
This commit is contained in:
Pavel Yaskevich
2023-04-21 09:46:09 -07:00
committed by Pavel Yaskevich
parent 38ee650719
commit 943ef19a1d
2 changed files with 11 additions and 9 deletions

View File

@@ -2412,13 +2412,16 @@ static PackType *replaceTypeVariablesWithFreshPacks(ConstraintSystem &cs,
auto elementLoc = cs.getConstraintLocator(loc,
LocatorPathElt::PackElement(freshTypeVars.size()));
if (packExpansionElt != nullptr) {
auto *freshTypeVar =
cs.createTypeVariable(elementLoc, TVO_CanBindToPack);
auto *freshTypeVar = cs.createTypeVariable(
elementLoc,
TVO_CanBindToPack |
(typeVar->getImpl().canBindToHole() ? TVO_CanBindToHole : 0));
freshTypeVars.push_back(PackExpansionType::get(
freshTypeVar, packExpansionElt->getCountType()));
} else {
freshTypeVars.push_back(
cs.createTypeVariable(elementLoc, /*options=*/0));
freshTypeVars.push_back(cs.createTypeVariable(
elementLoc,
typeVar->getImpl().canBindToHole() ? TVO_CanBindToHole : 0));
}
}
}