Merge pull request #61321 from DougGregor/open-existential-for-optional-param

This commit is contained in:
Doug Gregor
2022-10-26 20:54:22 -07:00
committed by GitHub
3 changed files with 20 additions and 11 deletions

View File

@@ -1620,8 +1620,10 @@ shouldOpenExistentialCallArgument(
if (param->isVariadic())
return None;
// Look through an inout type on the formal type of the parameter.
auto formalParamTy = param->getInterfaceType()->getInOutObjectType();
// Look through an inout and optional types on the formal type of the
// parameter.
auto formalParamTy = param->getInterfaceType()->getInOutObjectType()
->lookThroughSingleOptionalType();
// If the argument is of an existential metatype, look through the
// metatype on the parameter.
@@ -1630,8 +1632,8 @@ shouldOpenExistentialCallArgument(
paramTy = paramTy->getMetatypeInstanceType();
}
// Look through an inout type on the parameter.
paramTy = paramTy->getInOutObjectType();
// Look through an inout and optional types on the parameter.
paramTy = paramTy->getInOutObjectType()->lookThroughSingleOptionalType();
// The parameter type must be a type variable.
auto paramTypeVar = paramTy->getAs<TypeVariableType>();