Skip to content

Commit 70757ff

Browse files
authored
Merge pull request #72570 from ahoppen/ahoppen/parameter-pack-pattern-crash
[CodeCompletion] Fix a crash when completing the call pattern of a function that takes a parameter pack
2 parents 4d01890 + 078e1ea commit 70757ff

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,15 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
9898
TypeSubstitutionMap subs;
9999
for (const auto &opened : openedTypes->second) {
100100
auto type = getFixedType(opened.second);
101-
if (opened.first->isParameterPack() && !type->is<PackType>())
102-
type = PackType::getSingletonPackExpansion(type);
101+
if (opened.first->isParameterPack()) {
102+
if (type->is<PlaceholderType>()) {
103+
auto &ctx = type->getASTContext();
104+
type =
105+
PackType::get(ctx, {PackExpansionType::get(ctx.TheUnresolvedType,
106+
ctx.TheUnresolvedType)});
107+
} else if (!type->is<PackType>())
108+
type = PackType::getSingletonPackExpansion(type);
109+
}
103110
subs[opened.first] = type;
104111
}
105112

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %batch-code-completion
2+
3+
struct Mixer<each Source: Signal>: Signal {}
4+
5+
print(Mixer(#^COMPLETE^#))
6+
7+
// COMPLETE: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['('][')'][#Mixer<repeat each Source>#];

0 commit comments

Comments
 (0)