mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #82238 from slavapestov/coding-keys-parameter-pack
Sema: Relax enum parameter pack restriction for CodingKeys
This commit is contained in:
@@ -6366,6 +6366,9 @@ ConstructorDecl *NominalTypeDecl::getDefaultInitializer() const {
|
||||
}
|
||||
|
||||
void NominalTypeDecl::synthesizeSemanticMembersIfNeeded(DeclName member) {
|
||||
if (isa<ProtocolDecl>(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
|
||||
|
||||
@@ -1364,6 +1364,8 @@ evaluator::SideEffect
|
||||
ResolveImplicitMemberRequest::evaluate(Evaluator &evaluator,
|
||||
NominalTypeDecl *target,
|
||||
ImplicitMemberAction action) const {
|
||||
ASSERT(!isa<ProtocolDecl>(target));
|
||||
|
||||
// FIXME: This entire request is a layering violation made of smaller,
|
||||
// finickier layering violations. See rdar://56844567
|
||||
|
||||
|
||||
@@ -2941,7 +2941,7 @@ static ArrayRef<Decl *> evaluateMembersRequest(
|
||||
}
|
||||
}
|
||||
|
||||
if (nominal) {
|
||||
if (nominal && !isa<ProtocolDecl>(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.
|
||||
|
||||
@@ -3226,11 +3226,13 @@ public:
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple
|
||||
|
||||
// We should accept this:
|
||||
|
||||
public struct HasPack<each T>: Codable {
|
||||
var x: String?
|
||||
}
|
||||
Reference in New Issue
Block a user