mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Promote various macro features to baseline.
This commit is contained in:
@@ -172,15 +172,15 @@ BASELINE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)")
|
||||
BASELINE_LANGUAGE_FEATURE(AssociatedTypeAvailability, 0, "Availability on associated types")
|
||||
BASELINE_LANGUAGE_FEATURE(AsyncSequenceFailure, 0, "Failure associated type on AsyncSequence and AsyncIteratorProtocol")
|
||||
BASELINE_LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors")
|
||||
LANGUAGE_FEATURE(Macros, 0, "Macros")
|
||||
LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
|
||||
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")
|
||||
LANGUAGE_FEATURE(ExtensionMacros, 402, "Extension macros")
|
||||
BASELINE_LANGUAGE_FEATURE(Macros, 0, "Macros")
|
||||
BASELINE_LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
|
||||
BASELINE_LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")
|
||||
BASELINE_LANGUAGE_FEATURE(ExtensionMacros, 402, "Extension macros")
|
||||
LANGUAGE_FEATURE(MoveOnly, 390, "noncopyable types")
|
||||
LANGUAGE_FEATURE(MoveOnlyResilientTypes, 390, "non-@frozen noncopyable types with library evolution")
|
||||
BASELINE_LANGUAGE_FEATURE(ParameterPacks, 393, "Value and type parameter packs")
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(LexicalLifetimes, 0, "@_eagerMove/@_noEagerMove/@_lexicalLifetimes annotations")
|
||||
LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
|
||||
BASELINE_LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(ExtensionMacroAttr, 0, "@attached(extension)")
|
||||
LANGUAGE_FEATURE(TypedThrows, 413, "Typed throws")
|
||||
|
||||
@@ -141,32 +141,6 @@ static bool usesFeatureSpecializeAttributeWithAvailability(Decl *decl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool usesFeatureMacros(Decl *decl) { return isa<MacroDecl>(decl); }
|
||||
|
||||
static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {
|
||||
auto macro = dyn_cast<MacroDecl>(decl);
|
||||
if (!macro)
|
||||
return false;
|
||||
|
||||
return macro->getMacroRoles().contains(MacroRole::Expression);
|
||||
}
|
||||
|
||||
static bool usesFeatureAttachedMacros(Decl *decl) {
|
||||
auto macro = dyn_cast<MacroDecl>(decl);
|
||||
if (!macro)
|
||||
return false;
|
||||
|
||||
return static_cast<bool>(macro->getMacroRoles() & getAttachedMacroRoles());
|
||||
}
|
||||
|
||||
static bool usesFeatureExtensionMacros(Decl *decl) {
|
||||
auto macro = dyn_cast<MacroDecl>(decl);
|
||||
if (!macro)
|
||||
return false;
|
||||
|
||||
return macro->getMacroRoles().contains(MacroRole::Extension);
|
||||
}
|
||||
|
||||
static bool usesFeatureMoveOnly(Decl *decl) {
|
||||
if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
|
||||
if (auto *nominal = extension->getExtendedNominal())
|
||||
@@ -229,14 +203,6 @@ static bool usesFeatureLexicalLifetimes(Decl *decl) {
|
||||
decl->getAttrs().hasAttribute<LexicalLifetimesAttr>();
|
||||
}
|
||||
|
||||
static bool usesFeatureFreestandingMacros(Decl *decl) {
|
||||
auto macro = dyn_cast<MacroDecl>(decl);
|
||||
if (!macro)
|
||||
return false;
|
||||
|
||||
return macro->getMacroRoles().contains(MacroRole::Declaration);
|
||||
}
|
||||
|
||||
static bool usesFeatureRetroactiveAttribute(Decl *decl) {
|
||||
auto ext = dyn_cast<ExtensionDecl>(decl);
|
||||
if (!ext)
|
||||
|
||||
@@ -9,51 +9,31 @@
|
||||
// RUN: %FileCheck %s < %t/Macros.swiftinterface --check-prefix CHECK
|
||||
// RUN: %target-swift-frontend -compile-module-from-interface %t/Macros.swiftinterface -o %t/Macros.swiftmodule
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
|
||||
// CHECK-NEXT: @freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
// CHECK: @freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
|
||||
@freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
|
||||
// CHECK: @freestanding(expression) public macro labeledStringify<T>(_ value: T, label: Swift.String) -> (T, Swift.String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
@freestanding(expression) public macro labeledStringify<T>(_ value: T, label: String) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
|
||||
// CHECK: @freestanding(expression) public macro unlabeledStringify<T>(_ value: T, label: Swift.String) -> (T, Swift.String) = #labeledStringify(value, label: "default label")
|
||||
// CHECK-NEXT: #endif
|
||||
@freestanding(expression) public macro unlabeledStringify<T>(_ value: T, label: String) -> (T, String) = #labeledStringify(value, label: "default label")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
|
||||
// CHECK: @freestanding(expression) public macro publicLine<T>() -> T = #externalMacro(module: "MacroDefinition", type: "Line") where T : Swift.ExpressibleByIntegerLiteral
|
||||
// CHECK-NEXT: #endif
|
||||
@freestanding(expression) public macro publicLine<T: ExpressibleByIntegerLiteral>() -> T = #externalMacro(module: "MacroDefinition", type: "Line")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros
|
||||
// CHECK: @attached(accessor) public macro myWrapper() = #externalMacro(module: "MacroDefinition", type: "Wrapper")
|
||||
// CHECK-NEXT: #endif
|
||||
@attached(accessor) public macro myWrapper() = #externalMacro(module: "MacroDefinition", type: "Wrapper")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
|
||||
// CHECK: @attached(member, names: named(init), prefixed(`$`)) public macro MemberwiseInit() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
@attached(member, names: named(init), prefixed(`$`)) public macro MemberwiseInit() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitMacro")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
|
||||
// CHECK: @attached(member, names: named(`init`), prefixed(`$`)) public macro MemberwiseInitFunc() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitFuncMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
@attached(member, names: named(`init`), prefixed(`$`)) public macro MemberwiseInitFunc() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitFuncMacro")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
|
||||
// CHECK: @attached(accessor, names: named(init)) public macro AccessorInitFunc() = #externalMacro(module: "MacroDefinition", type: "AccessorInitFuncMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
@attached(accessor, names: named(init)) public macro AccessorInitFunc() = #externalMacro(module: "MacroDefinition", type: "AccessorInitFuncMacro")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
|
||||
// CHECK: @attached(extension, conformances: Swift.Sendable) @attached(member) public macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableExtensionMacro")
|
||||
// CHECK-NEXT: #else
|
||||
// CHECK: @attached(member) public macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableExtensionMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
@attached(extension, conformances: Sendable) @attached(member) public macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableExtensionMacro")
|
||||
|
||||
// CHECK-NOT: internalStringify
|
||||
|
||||
Reference in New Issue
Block a user