Skip to content

Commit 5665705

Browse files
authored
Merge pull request #64139 from DougGregor/if-macro-decls-stdlib
[Macros] Add #ifs around macro declarations in standard library
2 parents 739cc2a + 2ac6aba commit 5665705

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

stdlib/public/Observation/Sources/Observation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_swift_target_library(swiftObservation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS
2727

2828
SWIFT_COMPILE_FLAGS
2929
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
30+
"-enable-experimental-feature" "Macros"
3031

3132
C_COMPILE_FLAGS
3233
${swift_runtime_library_compile_flags}

stdlib/public/Observation/Sources/Observation/Macros.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
#if $Macros && hasAttribute(attached)
13+
1214
@available(SwiftStdlib 5.9, *)
1315
@attached(member, names: named(_registrar), named(transactions), named(changes), named(_Storage), named(_storage))
1416
@attached(memberAttribute)
@@ -20,3 +22,5 @@ public macro Observable() =
2022
@attached(accessor)
2123
public macro ObservableProperty() =
2224
#externalMacro(module: "ObservationMacros", type: "ObservablePropertyMacro")
25+
26+
#endif

stdlib/public/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ endif()
289289
# STAGING: Temporarily avoids having to write #fileID in Swift.swiftinterface.
290290
list(APPEND swift_stdlib_compile_flags "-Xfrontend" "-enable-experimental-concise-pound-file")
291291

292+
list(APPEND swift_stdlib_compile_flags "-enable-experimental-feature" "Macros")
293+
292294
if(SWIFT_CHECK_ESSENTIAL_STDLIB)
293295
add_swift_target_library(swift_stdlib_essential ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB IS_STDLIB_CORE
294296
INSTALL_IN_COMPONENT never_install

stdlib/public/core/Macros.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if $Macros && hasAttribute(attached)
14+
1315
/// Specifies the module and type name for an externally-defined macro, which
1416
/// must conform to the appropriate set of `Macro` protocols.
1517
///
@@ -90,3 +92,5 @@ public macro dsohandle() -> UnsafeRawPointer = Builtin.DSOHandleMacro
9092
@attached(conformance)
9193
public macro OptionSet<RawType>() =
9294
#externalMacro(module: "SwiftMacros", type: "OptionSetMacro")
95+
96+
#endif

0 commit comments

Comments
 (0)