diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 345a155cc805f..5fb2b2208d5cc 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -6363,6 +6363,9 @@ ConstructorDecl *NominalTypeDecl::getDefaultInitializer() const { } void NominalTypeDecl::synthesizeSemanticMembersIfNeeded(DeclName member) { + if (isa(this)) + return; + // Silently break cycles here because we can't be sure when and where a // request to synthesize will come from yet. // FIXME: rdar://56844567 diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index 3fd3c836ecc08..1df20c0397884 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -1364,6 +1364,8 @@ evaluator::SideEffect ResolveImplicitMemberRequest::evaluate(Evaluator &evaluator, NominalTypeDecl *target, ImplicitMemberAction action) const { + ASSERT(!isa(target)); + // FIXME: This entire request is a layering violation made of smaller, // finickier layering violations. See rdar://56844567 diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index 9832d239c83b0..abce1b3299457 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -2941,7 +2941,7 @@ static ArrayRef evaluateMembersRequest( } } - if (nominal) { + if (nominal && !isa(nominal)) { // If the type conforms to Encodable or Decodable, even via an extension, // the CodingKeys enum is synthesized as a member of the type itself. // Force it into existence. diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index f15b6df14825c..9689ba1557287 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -3226,11 +3226,13 @@ class DeclChecker : public DeclVisitor { // Temporary restriction until we figure out pattern matching and // enum case construction with packs. - if (auto genericSig = ED->getGenericSignature()) { - for (auto paramTy : genericSig.getGenericParams()) { - if (paramTy->isParameterPack()) { - ED->diagnose(diag::enum_with_pack); - break; + if (!ED->isSynthesized()) { + if (auto genericSig = ED->getGenericSignature()) { + for (auto paramTy : genericSig.getGenericParams()) { + if (paramTy->isParameterPack()) { + ED->diagnose(diag::enum_with_pack); + break; + } } } } diff --git a/test/decl/protocol/special/coding/codable_parameter_pack.swift b/test/decl/protocol/special/coding/codable_parameter_pack.swift new file mode 100644 index 0000000000000..310e133328b56 --- /dev/null +++ b/test/decl/protocol/special/coding/codable_parameter_pack.swift @@ -0,0 +1,7 @@ +// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple + +// We should accept this: + +public struct HasPack: Codable { + var x: String? +}