Skip to content

Commit 9a7b9c6

Browse files
committed
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.
1 parent 33be0be commit 9a7b9c6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,11 @@ shouldOpenExistentialCallArgument(
13541354
break;
13551355
}
13561356

1357+
// C++ function templates require specialization, which is not possible with
1358+
// opened existential archetypes, so do not open.
1359+
if (isa_and_nonnull<clang::FunctionTemplateDecl>(callee->getClangDecl()))
1360+
return None;
1361+
13571362
ASTContext &ctx = callee->getASTContext();
13581363
if (!ctx.LangOpts.EnableOpenedExistentialTypes)
13591364
return None;

test/Interop/Cxx/templates/function-template.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
2+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop -Xfrontend -enable-experimental-opened-existential-types)
23
//
34
// REQUIRES: executable_test
45

0 commit comments

Comments
 (0)