diff --git a/include/swift/AST/DeclAttr.def b/include/swift/AST/DeclAttr.def index f82320d0237..2ae26cb2c3c 100644 --- a/include/swift/AST/DeclAttr.def +++ b/include/swift/AST/DeclAttr.def @@ -880,6 +880,7 @@ SIMPLE_DECL_ATTR(extensible, Extensible, OnEnum, ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove | ForbiddenInABIAttr, 169) +DECL_ATTR_FEATURE_REQUIREMENT(Extensible, ExtensibleAttribute) SIMPLE_DECL_ATTR(concurrent, Concurrent, OnFunc | OnConstructor | OnSubscript | OnVar, diff --git a/test/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index 4c0970de2f1..a7104e38d3d 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -344,7 +344,6 @@ struct _S { // ON_MEMBER_LAST-DAG: Keyword/None: freestanding[#Declaration Attribute#]; name=freestanding // ON_MEMBER_LAST-DAG: Keyword/None: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions // ON_MEMBER_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime -// ON_MEMBER_LAST-DAG: Keyword/None: extensible[#Declaration Attribute#]; name=extensible // ON_MEMBER_LAST-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent // ON_MEMBER_LAST-NOT: Keyword // ON_MEMBER_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct @@ -421,7 +420,6 @@ func dummy2() {} // KEYWORD_LAST-DAG: Keyword/None: attached[#Declaration Attribute#]; name=attached // KEYWORD_LAST-DAG: Keyword/None: storageRestrictions[#Declaration Attribute#]; name=storageRestrictions // KEYWORD_LAST-DAG: Keyword/None: lifetime[#Declaration Attribute#]; name=lifetime -// KEYWORD_LAST-DAG: Keyword/None: extensible[#Declaration Attribute#]; name=extensible // KEYWORD_LAST-DAG: Keyword/None: concurrent[#Declaration Attribute#]; name=concurrent // KEYWORD_LAST-NOT: Keyword // KEYWORD_LAST-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct diff --git a/test/IDE/complete_decl_attribute_feature_requirement.swift b/test/IDE/complete_decl_attribute_feature_requirement.swift index 461666a5e1f..256f5da3345 100644 --- a/test/IDE/complete_decl_attribute_feature_requirement.swift +++ b/test/IDE/complete_decl_attribute_feature_requirement.swift @@ -12,7 +12,8 @@ // RUN: %batch-code-completion -filecheck-additional-suffix _DISABLED // RUN: %batch-code-completion -filecheck-additional-suffix _ENABLED \ -// RUN: -enable-experimental-feature ABIAttribute +// RUN: -enable-experimental-feature ABIAttribute \ +// RUN: -enable-experimental-feature ExtensibleAttribute // NOTE: Please do not include the ", N items" after "Begin completions". The // item count creates needless merge conflicts given that an "End completions" @@ -39,6 +40,8 @@ // KEYWORD4: Begin completions // KEYWORD4_ENABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi // KEYWORD4_DISABLED-NOT: Keyword/None: abi[#{{.*}} Attribute#]; name=abi +// KEYWORD4_ENABLED-DAG: Keyword/None: extensible[#{{.*}} Attribute#]; name=extensible +// KEYWORD4_DISABLED-NOT: Keyword/None: extensible[#{{.*}} Attribute#]; name=extensible // KEYWORD4: End completions @#^KEYWORD5^# struct S{} diff --git a/test/ModuleInterface/extensible_enums.swift b/test/ModuleInterface/extensible_enums.swift index e23a19b6eff..8f8bf96952b 100644 --- a/test/ModuleInterface/extensible_enums.swift +++ b/test/ModuleInterface/extensible_enums.swift @@ -5,7 +5,8 @@ /// Build the library // RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \ // RUN: -module-name Lib \ -// RUN: -emit-module-path %t/Lib.swiftmodule +// RUN: -emit-module-path %t/Lib.swiftmodule \ +// RUN: -enable-experimental-feature ExtensibleAttribute // Check that the errors are produced when using enums from module with `ExtensibleEnums` feature enabled. // RUN: %target-swift-frontend -typecheck %t/src/TestChecking.swift \ @@ -18,7 +19,9 @@ // RUN: %target-swift-frontend -emit-module %t/src/Lib.swift \ // RUN: -module-name Lib \ // RUN: -package-name Test \ -// RUN: -emit-module-path %t/Lib.swiftmodule +// RUN: -emit-module-path %t/Lib.swiftmodule \ +// RUN: -enable-experimental-feature ExtensibleAttribute + // Different module but the same package // RUN: %target-swift-frontend -typecheck %t/src/TestSamePackage.swift \ @@ -26,6 +29,8 @@ // RUN: -package-name Test \ // RUN: -verify +// REQUIRES: swift_feature_ExtensibleAttribute + //--- Lib.swift @extensible diff --git a/test/attr/attr_extensible.swift b/test/attr/attr_extensible.swift index 60eabf9574c..63e49848cfe 100644 --- a/test/attr/attr_extensible.swift +++ b/test/attr/attr_extensible.swift @@ -1,4 +1,6 @@ -// RUN: %target-typecheck-verify-swift +// RUN: %target-typecheck-verify-swift -enable-experimental-feature ExtensibleAttribute + +// REQUIRES: swift_feature_ExtensibleAttribute @extensible public enum E1 { // Ok diff --git a/test/attr/feature_requirement.swift b/test/attr/feature_requirement.swift index d8e6121311b..e7dfb35f2f1 100644 --- a/test/attr/feature_requirement.swift +++ b/test/attr/feature_requirement.swift @@ -1,5 +1,5 @@ // RUN: %target-typecheck-verify-swift -parse-as-library -disable-experimental-parser-round-trip -verify-additional-prefix disabled- -// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature CompileTimeValues +// RUN: %target-typecheck-verify-swift -parse-as-library -verify-additional-prefix enabled- -enable-experimental-feature CompileTimeValues -enable-experimental-feature ExtensibleAttribute // REQUIRES: asserts @@ -14,3 +14,13 @@ public let x = 1 // expected-disabled-error@-1 {{'const' attribute is only vali #else #error("doesn't have @const") // expected-disabled-error {{doesn't have @const}} #endif + +@extensible +public enum E {} // expected-disabled-error@-1 {{'extensible' attribute is only valid when experimental feature ExtensibleAttribute is enabled}} + +#if hasAttribute(extensible) + #error("does have @extensible") // expected-enabled-error {{does have @extensible}} +#else + #error("doesn't have @extensible") // expected-disabled-error {{doesn't have @extensible}} +#endif +