Skip to content

Commit 9a101ca

Browse files
committed
Sema: Relax enum parameter pack restriction for CodingKeys
1 parent 84997b4 commit 9a101ca

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,11 +3226,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
32263226

32273227
// Temporary restriction until we figure out pattern matching and
32283228
// enum case construction with packs.
3229-
if (auto genericSig = ED->getGenericSignature()) {
3230-
for (auto paramTy : genericSig.getGenericParams()) {
3231-
if (paramTy->isParameterPack()) {
3232-
ED->diagnose(diag::enum_with_pack);
3233-
break;
3229+
if (!ED->isSynthesized()) {
3230+
if (auto genericSig = ED->getGenericSignature()) {
3231+
for (auto paramTy : genericSig.getGenericParams()) {
3232+
if (paramTy->isParameterPack()) {
3233+
ED->diagnose(diag::enum_with_pack);
3234+
break;
3235+
}
32343236
}
32353237
}
32363238
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple
2+
3+
// We should accept this:
4+
5+
public struct HasPack<each T>: Codable {
6+
var x: String?
7+
}

0 commit comments

Comments
 (0)