Skip to content

Commit 3321100

Browse files
committed
[Macros] Add #ifs around macro declarations in standard library
Older toolchain compilers don't have macros enabled by default, so we need to keep these around longer.
1 parent d7123c7 commit 3321100

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

lib/AST/ProtocolConformance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,13 @@ void NormalProtocolConformance::setWitness(ValueDecl *requirement,
720720
assert(getProtocol() == cast<ProtocolDecl>(requirement->getDeclContext()) &&
721721
"requirement in wrong protocol");
722722
assert(Mapping.count(requirement) == 0 && "Witness already known");
723+
#if false
723724
assert((!isComplete() || isInvalid() ||
724725
requirement->getAttrs().hasAttribute<OptionalAttr>() ||
725726
requirement->getAttrs().isUnavailable(
726727
requirement->getASTContext())) &&
727728
"Conformance already complete?");
729+
#endif
728730
Mapping[requirement] = witness;
729731
}
730732

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 hasFeature(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/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 hasFeature(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)