[cxx-interop] Do not import function templates with a parameter pack - #91410
Open
patrykstefanski wants to merge 1 commit into
Open
[cxx-interop] Do not import function templates with a parameter pack#91410patrykstefanski wants to merge 1 commit into
patrykstefanski wants to merge 1 commit into
Conversation
A pack `typename... Ts` is a clang::TemplateTypeParmDecl, so the
existing "all template parameters must be template type parameters"
guard in VisitFunctionTemplateDecl let it through. The pack collapsed
into a single ordinary generic parameter and the pack expansion
parameter was imported as Any:
func parameterPack<Ts>(_ ts: Any, Ts: Ts.Type)
Calling that from Swift triggers an assertion in getPackAsArray().
Bail on packs instead, the way non-type template parameters are already
treated, so a call site gets "cannot find 'parameterPack' in scope"
rather than an assertion failure.
rdar://184658782
patrykstefanski
requested review from
Xazax-hun,
beccadax,
egorzhdan,
hamishknight,
hborla,
hnrklssn,
ian-twilightcoder,
j-hui,
slavapestov,
susmonteiro and
xedin
as code owners
August 11, 2026 23:27
Contributor
Author
|
@swift-ci please test |
Xazax-hun
approved these changes
Aug 12, 2026
egorzhdan
approved these changes
Aug 12, 2026
Comment on lines
+5015
to
+5017
| const auto *typeParam = | ||
| dyn_cast<clang::TemplateTypeParmDecl>(param); | ||
| return typeParam && !typeParam->isParameterPack(); |
Contributor
There was a problem hiding this comment.
We could probably hoist this check into importNameImpl and save some cycles on name lookup. I don't think this is very important though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A pack
typename... Tsis a clang::TemplateTypeParmDecl, so the existing "all template parameters must be template type parameters" guard in VisitFunctionTemplateDecl let it through. The pack collapsed into a single ordinary generic parameter and the pack expansion parameter was imported as Any:Calling that from Swift triggers an assertion in getPackAsArray().
Bail on packs instead, the way non-type template parameters are already treated, so a call site gets "cannot find 'parameterPack' in scope" rather than an assertion failure.
rdar://184658782