mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Introduce a separate feature to cover @freestanding(expression)
This commit is contained in:
@@ -92,6 +92,9 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync", true)
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)", true)
|
||||
LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors", true)
|
||||
LANGUAGE_FEATURE(
|
||||
FreestandingExpressionMacros, 0, "@freestanding(expression) macros",
|
||||
langOpts.hasFeature(Feature::Macros))
|
||||
|
||||
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
|
||||
UPCOMING_FEATURE(ForwardTrailingClosures, 286, 6)
|
||||
|
||||
@@ -3171,6 +3171,14 @@ static bool usesFeatureBuiltinMacros(Decl *decl) {
|
||||
|
||||
static bool usesFeatureImportSymbolicCXXDecls(Decl *decl) { return false; }
|
||||
|
||||
static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {
|
||||
auto macro = dyn_cast<MacroDecl>(decl);
|
||||
if (!macro)
|
||||
return false;
|
||||
|
||||
return macro->getMacroRoles().contains(MacroRole::Expression);
|
||||
}
|
||||
|
||||
static void
|
||||
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
// 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
|
||||
// CHECK: #if compiler(>=5.3) && $FreestandingExpressionMacros && $Macros
|
||||
// CHECK-NEXT: @freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")
|
||||
// CHECK-NEXT: #endif
|
||||
@freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $Macros
|
||||
// CHECK: #if compiler(>=5.3) && $FreestandingExpressionMacros && $Macros
|
||||
// CHECK: @freestanding(expression) public macro publicLine<T>: T = #externalMacro(module: "SomeModule", type: "Line") where T : Swift.ExpressibleByIntegerLiteral
|
||||
// CHECK-NEXT: #endif
|
||||
@freestanding(expression) public macro publicLine<T: ExpressibleByIntegerLiteral>: T = #externalMacro(module: "SomeModule", type: "Line")
|
||||
|
||||
Reference in New Issue
Block a user