Skip to content

Commit 0b838fc

Browse files
committed
[SE-0415] Enable function body macros by default
Preamble macros are *not* part of the revised SE-0415, so leave them experimental. Tracked by rdar://119687390.
1 parent a98b6e9 commit 0b838fc

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

include/swift/Basic/Features.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ LANGUAGE_FEATURE(BitwiseCopyable, 426, "BitwiseCopyable protocol")
195195
SUPPRESSIBLE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
196196
SUPPRESSIBLE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
197197
SUPPRESSIBLE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
198+
LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
198199

199200
// Swift 6
200201
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -224,7 +225,7 @@ EXPERIMENTAL_FEATURE(StaticAssert, false)
224225
EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false)
225226
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures, false)
226227
EXPERIMENTAL_FEATURE(CodeItemMacros, false)
227-
EXPERIMENTAL_FEATURE(BodyMacros, true)
228+
EXPERIMENTAL_FEATURE(PreambleMacros, false)
228229
EXPERIMENTAL_FEATURE(TupleConformances, false)
229230
EXPERIMENTAL_FEATURE(FullTypedThrows, true)
230231

include/swift/Basic/MacroRoles.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ EXPERIMENTAL_FREESTANDING_MACRO_ROLE(CodeItem, "codeItem", CodeItemMacros)
7575
ATTACHED_MACRO_ROLE(Extension, "extension", "e")
7676

7777
/// An attached macro that expands to a preamble to a function.
78-
EXPERIMENTAL_ATTACHED_MACRO_ROLE(Preamble, "preamble", "q", BodyMacros)
78+
EXPERIMENTAL_ATTACHED_MACRO_ROLE(Preamble, "preamble", "q", PreambleMacros)
7979

8080
/// An attached macro that expands to a function body.
81-
EXPERIMENTAL_ATTACHED_MACRO_ROLE(Body, "body", "b", BodyMacros)
81+
ATTACHED_MACRO_ROLE(Body, "body", "b")
8282

8383
#undef ATTACHED_MACRO_ROLE
8484
#undef FREESTANDING_MACRO_ROLE

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ static bool usesFeatureCodeItemMacros(Decl *decl) {
414414
}
415415

416416
UNINTERESTING_FEATURE(BodyMacros)
417+
UNINTERESTING_FEATURE(PreambleMacros)
417418
UNINTERESTING_FEATURE(TupleConformances)
418419

419420
static bool usesFeatureSymbolLinkageMarkers(Decl *decl) {

lib/ASTGen/Sources/ASTGen/SourceFile.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extension Parser.ExperimentalFeatures {
5656
insert(feature)
5757
}
5858
}
59+
5960
mapFeature(.ThenStatements, to: .thenStatements)
6061
mapFeature(.DoExpressions, to: .doExpressions)
6162
mapFeature(.NonescapableTypes, to: .nonescapableTypes)

test/IDE/complete_macro_attribute.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ macro FreestandingMacro
1010
@attached(#^ATTACHED_ROLE^#)
1111
macro AttachedMacro
1212

13-
// ATTACHED_ROLE: Begin completions, 6 items
13+
// ATTACHED_ROLE: Begin completions, 7 items
1414
// ATTACHED_ROLE-DAG: Keyword/None: accessor; name=accessor
15+
// ATTACHED_ROLE-DAG: Keyword/None: body; name=body
1516
// ATTACHED_ROLE-DAG: Keyword/None: memberAttribute; name=memberAttribute
1617
// ATTACHED_ROLE-DAG: Keyword/None: member; name=member
1718
// ATTACHED_ROLE-DAG: Keyword/None: peer; name=peer

test/Macros/macro_expand_body.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath -swift-version 5
44

55
// Diagnostics testing
6-
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-experimental-feature BodyMacros -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS
6+
// RUN: %target-typecheck-verify-swift -swift-version 5 -enable-experimental-feature PreambleMacros -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS
77

88
// Execution testing
9-
// RUN: %target-build-swift -swift-version 5 -g -enable-experimental-feature BodyMacros -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser
9+
// RUN: %target-build-swift -swift-version 5 -g -enable-experimental-feature PreambleMacros -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser
1010
// RUN: %target-codesign %t/main
1111
// RUN: %target-run %t/main | %FileCheck %s
1212

test/SourceKit/Macros/macro_basic.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func remoteCall<Result: ConjureRemoteValue>(function: String, arguments: [String
121121
return Result.conjureValue()
122122
}
123123

124-
// REQUIRES: swift_swift_parser, executable_test, shell
124+
// REQUIRES: swift_swift_parser, executable_test, shell, asserts
125125

126126
// RUN: %empty-directory(%t)
127127

@@ -132,7 +132,7 @@ func remoteCall<Result: ConjureRemoteValue>(function: String, arguments: [String
132132
// RUN: -swift-version 5 \
133133
// RUN: -load-plugin-library %t/%target-library-name(MacroDefinition) \
134134
// RUN: -module-name MacroUser \
135-
// RUN: -enable-experimental-feature BodyMacros \
135+
// RUN: -enable-experimental-feature PreambleMacros \
136136
// RUN: )
137137

138138
// RUN: COMPILER_ARGS=( \

0 commit comments

Comments
 (0)