Don't open existentials when calling C++ function templates

C++ function templates require specialization, which does not work with
opened existentials. Disable opening for them.
This commit is contained in:
Doug Gregor
2022-02-08 15:26:26 -08:00
parent 33be0beb12
commit 9a7b9c6216
2 changed files with 6 additions and 0 deletions

View File

@@ -1354,6 +1354,11 @@ shouldOpenExistentialCallArgument(
break;
}
// C++ function templates require specialization, which is not possible with
// opened existential archetypes, so do not open.
if (isa_and_nonnull<clang::FunctionTemplateDecl>(callee->getClangDecl()))
return None;
ASTContext &ctx = callee->getASTContext();
if (!ctx.LangOpts.EnableOpenedExistentialTypes)
return None;