Merge pull request #66708 from xedin/generalize-default-closure-type-constraint

[ConstraintSystem] Use fallback type constraint to default pack expansion
This commit is contained in:
Pavel Yaskevich
2023-06-19 00:47:18 -07:00
committed by GitHub
9 changed files with 91 additions and 51 deletions

View File

@@ -2284,7 +2284,7 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
case ConstraintKind::BridgingConversion:
case ConstraintKind::OneWayEqual:
case ConstraintKind::OneWayBindParam:
case ConstraintKind::DefaultClosureType:
case ConstraintKind::FallbackType:
case ConstraintKind::UnresolvedMemberChainBase:
case ConstraintKind::PropertyWrapper:
case ConstraintKind::SyntacticElement:
@@ -2643,7 +2643,7 @@ static bool matchFunctionRepresentations(FunctionType::ExtInfo einfo1,
case ConstraintKind::ValueWitness:
case ConstraintKind::OneWayEqual:
case ConstraintKind::OneWayBindParam:
case ConstraintKind::DefaultClosureType:
case ConstraintKind::FallbackType:
case ConstraintKind::UnresolvedMemberChainBase:
case ConstraintKind::PropertyWrapper:
case ConstraintKind::SyntacticElement:
@@ -3161,7 +3161,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
case ConstraintKind::BridgingConversion:
case ConstraintKind::OneWayEqual:
case ConstraintKind::OneWayBindParam:
case ConstraintKind::DefaultClosureType:
case ConstraintKind::FallbackType:
case ConstraintKind::UnresolvedMemberChainBase:
case ConstraintKind::PropertyWrapper:
case ConstraintKind::SyntacticElement:
@@ -6811,7 +6811,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
case ConstraintKind::ValueWitness:
case ConstraintKind::OneWayEqual:
case ConstraintKind::OneWayBindParam:
case ConstraintKind::DefaultClosureType:
case ConstraintKind::FallbackType:
case ConstraintKind::UnresolvedMemberChainBase:
case ConstraintKind::PropertyWrapper:
case ConstraintKind::SyntacticElement:
@@ -10989,18 +10989,18 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyDefaultableConstraint(
return SolutionKind::Solved;
}
ConstraintSystem::SolutionKind
ConstraintSystem::simplifyDefaultClosureTypeConstraint(
Type closureType, Type inferredType,
ArrayRef<TypeVariableType *> referencedOuterParameters,
TypeMatchOptions flags, ConstraintLocatorBuilder locator) {
closureType = getFixedTypeRecursive(closureType, flags, /*wantRValue=*/true);
ConstraintSystem::SolutionKind ConstraintSystem::simplifyFallbackTypeConstraint(
Type defaultableType, Type fallbackType,
ArrayRef<TypeVariableType *> referencedVars, TypeMatchOptions flags,
ConstraintLocatorBuilder locator) {
defaultableType =
getFixedTypeRecursive(defaultableType, flags, /*wantRValue=*/true);
if (closureType->isTypeVariableOrMember()) {
if (defaultableType->isTypeVariableOrMember()) {
if (flags.contains(TMF_GenerateConstraints)) {
addUnsolvedConstraint(Constraint::create(
*this, ConstraintKind::DefaultClosureType, closureType, inferredType,
getConstraintLocator(locator), referencedOuterParameters));
*this, ConstraintKind::FallbackType, defaultableType, fallbackType,
getConstraintLocator(locator), referencedVars));
return SolutionKind::Solved;
}
@@ -15065,7 +15065,7 @@ ConstraintSystem::addConstraintImpl(ConstraintKind kind, Type first,
case ConstraintKind::Conjunction:
case ConstraintKind::KeyPath:
case ConstraintKind::KeyPathApplication:
case ConstraintKind::DefaultClosureType:
case ConstraintKind::FallbackType:
case ConstraintKind::SyntacticElement:
llvm_unreachable("Use the correct addConstraint()");
}
@@ -15597,12 +15597,12 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
/*flags*/ None,
constraint.getLocator());
case ConstraintKind::DefaultClosureType:
return simplifyDefaultClosureTypeConstraint(constraint.getFirstType(),
constraint.getSecondType(),
constraint.getTypeVariables(),
/*flags*/ None,
constraint.getLocator());
case ConstraintKind::FallbackType:
return simplifyFallbackTypeConstraint(constraint.getFirstType(),
constraint.getSecondType(),
constraint.getTypeVariables(),
/*flags*/ None,
constraint.getLocator());
case ConstraintKind::PropertyWrapper:
return simplifyPropertyWrapperConstraint(constraint.getFirstType(),