[AST] Add helper methods to GenericTypeParamType for converting a given type

parameter to and from a pack type parameter.
This commit is contained in:
Holly Borla
2022-10-25 09:39:17 -07:00
parent e80ee92898
commit 1ab9f8f7c6
6 changed files with 30 additions and 23 deletions

View File

@@ -8432,6 +8432,7 @@ ConstraintSystem::SolutionKind
ConstraintSystem::simplifyPackElementOfConstraint(Type first, Type second,
TypeMatchOptions flags,
ConstraintLocatorBuilder locator) {
ASTContext &ctx = getASTContext();
auto elementType = simplifyType(first, flags);
auto *loc = getConstraintLocator(locator);
@@ -8454,10 +8455,7 @@ ConstraintSystem::simplifyPackElementOfConstraint(Type first, Type second,
return type;
auto *elementParam = element->mapTypeOutOfContext()->getAs<GenericTypeParamType>();
auto *pack = GenericTypeParamType::get(/*isParameterPack*/true,
elementParam->getDepth(),
elementParam->getIndex(),
this->getASTContext());
auto *pack = elementParam->asParameterPack(ctx);
return this->DC->mapTypeIntoContext(pack);
});