Merge pull request #36592 from drexin/wip-remove-codable-enum-flag

[Frontend] Remove enable-experimental-enum-codable-derivation flag
This commit is contained in:
Saleem Abdulrasool
2021-03-31 15:04:32 -07:00
committed by GitHub
23 changed files with 24 additions and 38 deletions

View File

@@ -273,9 +273,6 @@ namespace swift {
/// Enable inference of Sendable conformances for public types. /// Enable inference of Sendable conformances for public types.
bool EnableInferPublicSendable = false; bool EnableInferPublicSendable = false;
/// Enable experimental derivation of `Codable` for enums.
bool EnableExperimentalEnumCodableDerivation = false;
/// Disable the implicit import of the _Concurrency module. /// Disable the implicit import of the _Concurrency module.
bool DisableImplicitConcurrencyModuleImport = false; bool DisableImplicitConcurrencyModuleImport = false;

View File

@@ -237,10 +237,6 @@ def enable_experimental_flow_sensitive_concurrent_captures :
Flag<["-"], "enable-experimental-flow-sensitive-concurrent-captures">, Flag<["-"], "enable-experimental-flow-sensitive-concurrent-captures">,
HelpText<"Enable flow-sensitive concurrent captures">; HelpText<"Enable flow-sensitive concurrent captures">;
def enable_experimental_enum_codable_derivation :
Flag<["-"], "enable-experimental-enum-codable-derivation">,
HelpText<"Enable experimental derivation of Codable for enums">;
def enable_resilience : Flag<["-"], "enable-resilience">, def enable_resilience : Flag<["-"], "enable-resilience">,
HelpText<"Deprecated, use -enable-library-evolution instead">; HelpText<"Deprecated, use -enable-library-evolution instead">;
} }

View File

@@ -394,9 +394,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableExperimentalFlowSensitiveConcurrentCaptures |= Opts.EnableExperimentalFlowSensitiveConcurrentCaptures |=
Args.hasArg(OPT_enable_experimental_flow_sensitive_concurrent_captures); Args.hasArg(OPT_enable_experimental_flow_sensitive_concurrent_captures);
Opts.EnableExperimentalEnumCodableDerivation |=
Args.hasArg(OPT_enable_experimental_enum_codable_derivation);
Opts.DisableImplicitConcurrencyModuleImport |= Opts.DisableImplicitConcurrencyModuleImport |=
Args.hasArg(OPT_disable_implicit_concurrency_module_import); Args.hasArg(OPT_disable_implicit_concurrency_module_import);

View File

@@ -2014,9 +2014,7 @@ static bool canDeriveCodable(NominalTypeDecl *NTD,
// Structs, classes and enums can explicitly derive Encodable and Decodable // Structs, classes and enums can explicitly derive Encodable and Decodable
// conformance (explicitly meaning we can synthesize an implementation if // conformance (explicitly meaning we can synthesize an implementation if
// a type conforms manually). // a type conforms manually).
if (!isa<StructDecl>(NTD) && !isa<ClassDecl>(NTD) && if (!isa<StructDecl>(NTD) && !isa<ClassDecl>(NTD) && !isa<EnumDecl>(NTD)) {
!(NTD->getASTContext().LangOpts.EnableExperimentalEnumCodableDerivation
&& isa<EnumDecl>(NTD))) {
return false; return false;
} }
@@ -2039,8 +2037,7 @@ bool DerivedConformance::canDeriveEncodable(NominalTypeDecl *NTD) {
ValueDecl *DerivedConformance::deriveEncodable(ValueDecl *requirement) { ValueDecl *DerivedConformance::deriveEncodable(ValueDecl *requirement) {
// We can only synthesize Encodable for structs and classes. // We can only synthesize Encodable for structs and classes.
if (!isa<StructDecl>(Nominal) && !isa<ClassDecl>(Nominal) && if (!isa<StructDecl>(Nominal) && !isa<ClassDecl>(Nominal) &&
!(Context.LangOpts.EnableExperimentalEnumCodableDerivation !isa<EnumDecl>(Nominal))
&& isa<EnumDecl>(Nominal)))
return nullptr; return nullptr;
if (requirement->getBaseName() != Context.Id_encode) { if (requirement->getBaseName() != Context.Id_encode) {
@@ -2070,8 +2067,7 @@ ValueDecl *DerivedConformance::deriveEncodable(ValueDecl *requirement) {
ValueDecl *DerivedConformance::deriveDecodable(ValueDecl *requirement) { ValueDecl *DerivedConformance::deriveDecodable(ValueDecl *requirement) {
// We can only synthesize Encodable for structs and classes. // We can only synthesize Encodable for structs and classes.
if (!isa<StructDecl>(Nominal) && !isa<ClassDecl>(Nominal) && if (!isa<StructDecl>(Nominal) && !isa<ClassDecl>(Nominal) &&
!(Context.LangOpts.EnableExperimentalEnumCodableDerivation !isa<EnumDecl>(Nominal))
&& isa<EnumDecl>(Nominal)))
return nullptr; return nullptr;
if (requirement->getBaseName() != DeclBaseName::createConstructor()) { if (requirement->getBaseName() != DeclBaseName::createConstructor()) {

View File

@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -emit-ir %s -swift-version 4 -enable-experimental-enum-codable-derivation | %FileCheck %s // RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -emit-ir %s -swift-version 4 | %FileCheck %s
struct Struct<T> { struct Struct<T> {
var x: T var x: T

View File

@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -prespecialize-generic-metadata -target %module-target-future -emit-ir %s -swift-version 4 -enable-experimental-enum-codable-derivation | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment // RUN: %target-swift-frontend -prespecialize-generic-metadata -target %module-target-future -emit-ir %s -swift-version 4 | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment
// REQUIRES: VENDOR=apple || OS=linux-gnu // REQUIRES: VENDOR=apple || OS=linux-gnu
// UNSUPPORTED: CPU=i386 && OS=ios // UNSUPPORTED: CPU=i386 && OS=ios

View File

@@ -1,5 +1,5 @@
// RUN: %target-swift-frontend -emit-silgen %s -swift-version 4 -enable-experimental-enum-codable-derivation | %FileCheck -check-prefix CHECK -check-prefix CHECK-FRAGILE %s // RUN: %target-swift-frontend -emit-silgen %s -swift-version 4 | %FileCheck -check-prefix CHECK -check-prefix CHECK-FRAGILE %s
// RUN: %target-swift-frontend -emit-silgen %s -swift-version 4 -enable-library-evolution -enable-experimental-enum-codable-derivation | %FileCheck -check-prefix CHECK -check-prefix CHECK-RESILIENT %s // RUN: %target-swift-frontend -emit-silgen %s -swift-version 4 -enable-library-evolution | %FileCheck -check-prefix CHECK -check-prefix CHECK-RESILIENT %s
enum Enum<T> { enum Enum<T> {
case a(T), b(T) case a(T), b(T)

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// Simple enums with all Codable parameters whose CodingKeys come from a // Simple enums with all Codable parameters whose CodingKeys come from a
// typealias should get derived conformance to Codable. // typealias should get derived conformance to Codable.

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// Simple enums with all Codable parameters whose CodingKeys come from a // Simple enums with all Codable parameters whose CodingKeys come from a
// typealias should get derived conformance to Codable. // typealias should get derived conformance to Codable.

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
enum Duplicate : Codable { // expected-error {{type 'Duplicate' does not conform to protocol 'Decodable'}} enum Duplicate : Codable { // expected-error {{type 'Duplicate' does not conform to protocol 'Decodable'}}
// expected-error@-1 {{type 'Duplicate' does not conform to protocol 'Encodable'}} // expected-error@-1 {{type 'Duplicate' does not conform to protocol 'Encodable'}}

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift
enum EnumWithNonExcludedOptionalParameters : Codable { // expected-error {{type 'EnumWithNonExcludedOptionalParameters' does not conform to protocol 'Decodable'}} enum EnumWithNonExcludedOptionalParameters : Codable { // expected-error {{type 'EnumWithNonExcludedOptionalParameters' does not conform to protocol 'Decodable'}}
// expected-error@-1 {{type 'EnumWithNonExcludedOptionalParameters' does not conform to protocol 'Encodable'}} // expected-error@-1 {{type 'EnumWithNonExcludedOptionalParameters' does not conform to protocol 'Encodable'}}

View File

@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -verify -enable-experimental-enum-codable-derivation // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -swift-version 4 %s -verify
// Codable enum with non-Codable parameter. // Codable enum with non-Codable parameter.
enum E1 : Codable { enum E1 : Codable {

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
struct NonCodable {} struct NonCodable {}

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// Enums with a CodingKeys entity which is not a type should not derive // Enums with a CodingKeys entity which is not a type should not derive
// conformance. // conformance.

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// MARK: - Synthesized CodingKeys Enum // MARK: - Synthesized CodingKeys Enum

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
enum NonCodable : Hashable { enum NonCodable : Hashable {
func hash(into hasher: inout Hasher) {} func hash(into hasher: inout Hasher) {}

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// The order of cases in the case specific CodingKeys enum should not matter // The order of cases in the case specific CodingKeys enum should not matter
enum SimpleEnum : Codable { enum SimpleEnum : Codable {

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown
// Simple enums with all Codable parameters should get derived conformance to // Simple enums with all Codable parameters should get derived conformance to
// Codable. // Codable.

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4 -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4
enum Conditional<T> { enum Conditional<T> {
case a(x: T, y: T?) case a(x: T, y: T?)

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4 -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4
enum Conditional<T> { enum Conditional<T> {
case a(x: T, y: T?) case a(x: T, y: T?)

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4 -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4
// Simple enums where Codable conformance is added in extensions should derive // Simple enums where Codable conformance is added in extensions should derive
// conformance. // conformance.

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4 -enable-experimental-enum-codable-derivation // RUN: %target-typecheck-verify-swift -verify-ignore-unknown -swift-version 4
// Simple enums where Codable conformance is added in extensions should derive // Simple enums where Codable conformance is added in extensions should derive
// conformance, no matter which order the extension and type occur in. // conformance, no matter which order the extension and type occur in.

View File

@@ -1,2 +1,2 @@
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation %S/Inputs/enum_codable_simple_multi1.swift %S/Inputs/enum_codable_simple_multi2.swift // RUN: %target-typecheck-verify-swift -verify-ignore-unknown %S/Inputs/enum_codable_simple_multi1.swift %S/Inputs/enum_codable_simple_multi2.swift
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -enable-experimental-enum-codable-derivation %S/Inputs/enum_codable_simple_multi2.swift %S/Inputs/enum_codable_simple_multi1.swift // RUN: %target-typecheck-verify-swift -verify-ignore-unknown %S/Inputs/enum_codable_simple_multi2.swift %S/Inputs/enum_codable_simple_multi1.swift