Skip to content

Commit d8ca62d

Browse files
authored
Merge pull request #2956 from rintaro/no-pre-5.8
Drop '#if compiler(>=5.8)' guards
2 parents 081fc7e + 29fa1fc commit d8ca62d

19 files changed

+10
-220
lines changed

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

+3-8
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,12 @@ public struct KeywordSpec: IdentifierConvertible {
3838
///
3939
/// This is typically used to mark APIs as SPI when the keyword is part of an experimental language feature.
4040
public var apiAttributes: AttributeListSyntax {
41-
let attrList = AttributeListSyntax {
41+
AttributeListSyntax {
4242
if isExperimental {
43-
let experimentalSPI: AttributeListSyntax = """
44-
#if compiler(>=5.8)
45-
@_spi(ExperimentalLanguageFeatures)
46-
#endif
47-
"""
48-
experimentalSPI.with(\.trailingTrivia, .newline)
43+
AttributeSyntax("@_spi(ExperimentalLanguageFeatures)")
44+
.with(\.trailingTrivia, .newline)
4945
}
5046
}
51-
return attrList.with(\.trailingTrivia, attrList.isEmpty ? [] : .newline)
5247
}
5348

5449
/// Initializes a new `KeywordSpec` instance.

CodeGeneration/Sources/SyntaxSupport/Node.swift

+7-16
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,20 @@ public class Node: NodeChoiceConvertible {
9696
/// Retrieve the attributes that should be printed on any API for the
9797
/// generated node. If `forRaw` is true, this is for the raw syntax node.
9898
public func apiAttributes(forRaw: Bool = false) -> AttributeListSyntax {
99-
let attrList = AttributeListSyntax {
99+
AttributeListSyntax {
100100
if isExperimental {
101-
// SPI for enum cases currently requires Swift 5.8 to work correctly.
102-
let experimentalSPI: AttributeListSyntax = """
103-
#if compiler(>=5.8)
104-
@_spi(ExperimentalLanguageFeatures)
105-
#endif
106-
"""
107-
experimentalSPI.with(\.trailingTrivia, .newline)
101+
AttributeSyntax("@_spi(ExperimentalLanguageFeatures)")
102+
.with(\.trailingTrivia, .newline)
108103
}
109104
if let spi = self.spi {
110-
let spiAttr: AttributeListSyntax = """
111-
#if compiler(>=5.8)
112-
@_spi(\(spi))
113-
#endif
114-
"""
115-
spiAttr.with(\.trailingTrivia, .newline)
105+
AttributeSyntax("@_spi(\(spi))")
106+
.with(\.trailingTrivia, .newline)
116107
}
117108
if forRaw {
118-
"@_spi(RawSyntax)"
109+
AttributeSyntax("@_spi(RawSyntax)")
110+
.with(\.trailingTrivia, .newline)
119111
}
120112
}
121-
return attrList.with(\.trailingTrivia, attrList.isEmpty ? [] : .newline)
122113
}
123114

124115
public var apiAttributes: AttributeListSyntax {

Sources/SwiftParser/generated/Parser+TokenSpecSet.swift

-16
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ extension AccessorDeclSyntax {
3232
case mutableAddressWithOwner
3333
case mutableAddressWithNativeOwner
3434
case _read
35-
#if compiler(>=5.8)
3635
@_spi(ExperimentalLanguageFeatures)
37-
#endif
3836
case read
3937
case _modify
40-
#if compiler(>=5.8)
4138
@_spi(ExperimentalLanguageFeatures)
42-
#endif
4339
case modify
4440
case `init`
4541

@@ -3085,14 +3081,10 @@ extension OptionalBindingConditionSyntax {
30853081
case `let`
30863082
case `var`
30873083
case `inout`
3088-
#if compiler(>=5.8)
30893084
@_spi(ExperimentalLanguageFeatures)
3090-
#endif
30913085
case _mutating
30923086
case _borrowing
3093-
#if compiler(>=5.8)
30943087
@_spi(ExperimentalLanguageFeatures)
3095-
#endif
30963088
case _consuming
30973089

30983090
init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
@@ -4049,14 +4041,10 @@ extension ValueBindingPatternSyntax {
40494041
case `let`
40504042
case `var`
40514043
case `inout`
4052-
#if compiler(>=5.8)
40534044
@_spi(ExperimentalLanguageFeatures)
4054-
#endif
40554045
case _mutating
40564046
case _borrowing
4057-
#if compiler(>=5.8)
40584047
@_spi(ExperimentalLanguageFeatures)
4059-
#endif
40604048
case _consuming
40614049
case borrowing
40624050

@@ -4152,14 +4140,10 @@ extension VariableDeclSyntax {
41524140
case `let`
41534141
case `var`
41544142
case `inout`
4155-
#if compiler(>=5.8)
41564143
@_spi(ExperimentalLanguageFeatures)
4157-
#endif
41584144
case _mutating
41594145
case _borrowing
4160-
#if compiler(>=5.8)
41614146
@_spi(ExperimentalLanguageFeatures)
4162-
#endif
41634147
case _consuming
41644148

41654149
init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {

Sources/SwiftSyntax/generated/Keyword.swift

-14
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
2626
case _Class
2727
case _compilerInitialized
2828
case _const
29-
#if compiler(>=5.8)
3029
@_spi(ExperimentalLanguageFeatures)
31-
#endif
3230
case _consuming
3331
case _documentation
3432
case _dynamicReplacement
@@ -40,9 +38,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
4038
case _local
4139
case _modify
4240
case _move
43-
#if compiler(>=5.8)
4441
@_spi(ExperimentalLanguageFeatures)
45-
#endif
4642
case _mutating
4743
case _NativeClass
4844
case _NativeRefCountedObject
@@ -71,9 +67,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
7167
case _underlyingVersion
7268
case _UnknownLayout
7369
case _version
74-
#if compiler(>=5.8)
7570
@_spi(ExperimentalLanguageFeatures)
76-
#endif
7771
case abi
7872
case accesses
7973
case actor
@@ -112,9 +106,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
112106
case `default`
113107
case `defer`
114108
case `deinit`
115-
#if compiler(>=5.8)
116109
@_spi(ExperimentalLanguageFeatures)
117-
#endif
118110
case dependsOn
119111
case deprecated
120112
case derivative
@@ -166,9 +158,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
166158
case macro
167159
case message
168160
case metadata
169-
#if compiler(>=5.8)
170161
@_spi(ExperimentalLanguageFeatures)
171-
#endif
172162
case modify
173163
case module
174164
case mutableAddressWithNativeOwner
@@ -197,9 +187,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
197187
case `Protocol`
198188
case `protocol`
199189
case `public`
200-
#if compiler(>=5.8)
201190
@_spi(ExperimentalLanguageFeatures)
202-
#endif
203191
case read
204192
case reasync
205193
case renamed
@@ -211,9 +199,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
211199
case reverse
212200
case right
213201
case safe
214-
#if compiler(>=5.8)
215202
@_spi(ExperimentalLanguageFeatures)
216-
#endif
217203
case scoped
218204
case `self`
219205
case sending

Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift

-32
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
5656
visitAnyPost(node._syntaxNode)
5757
}
5858

59-
#if compiler(>=5.8)
6059
@_spi(ExperimentalLanguageFeatures)
61-
#endif
6260
override open func visit(_ node: ABIAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind {
6361
return visitAny(node._syntaxNode)
6462
}
6563

66-
#if compiler(>=5.8)
6764
@_spi(ExperimentalLanguageFeatures)
68-
#endif
6965
override open func visitPost(_ node: ABIAttributeArgumentsSyntax) {
7066
visitAnyPost(node._syntaxNode)
7167
}
@@ -238,16 +234,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
238234
visitAnyPost(node._syntaxNode)
239235
}
240236

241-
#if compiler(>=5.8)
242237
@_spi(Compiler)
243-
#endif
244238
override open func visit(_ node: AvailabilityMacroDefinitionSyntax) -> SyntaxVisitorContinueKind {
245239
return visitAny(node._syntaxNode)
246240
}
247241

248-
#if compiler(>=5.8)
249242
@_spi(Compiler)
250-
#endif
251243
override open func visitPost(_ node: AvailabilityMacroDefinitionSyntax) {
252244
visitAnyPost(node._syntaxNode)
253245
}
@@ -756,16 +748,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
756748
visitAnyPost(node._syntaxNode)
757749
}
758750

759-
#if compiler(>=5.8)
760751
@_spi(ExperimentalLanguageFeatures)
761-
#endif
762752
override open func visit(_ node: DoExprSyntax) -> SyntaxVisitorContinueKind {
763753
return visitAny(node._syntaxNode)
764754
}
765755

766-
#if compiler(>=5.8)
767756
@_spi(ExperimentalLanguageFeatures)
768-
#endif
769757
override open func visitPost(_ node: DoExprSyntax) {
770758
visitAnyPost(node._syntaxNode)
771759
}
@@ -1370,44 +1358,32 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
13701358
visitAnyPost(node._syntaxNode)
13711359
}
13721360

1373-
#if compiler(>=5.8)
13741361
@_spi(ExperimentalLanguageFeatures)
1375-
#endif
13761362
override open func visit(_ node: LifetimeSpecifierArgumentListSyntax) -> SyntaxVisitorContinueKind {
13771363
return visitAny(node._syntaxNode)
13781364
}
13791365

1380-
#if compiler(>=5.8)
13811366
@_spi(ExperimentalLanguageFeatures)
1382-
#endif
13831367
override open func visitPost(_ node: LifetimeSpecifierArgumentListSyntax) {
13841368
visitAnyPost(node._syntaxNode)
13851369
}
13861370

1387-
#if compiler(>=5.8)
13881371
@_spi(ExperimentalLanguageFeatures)
1389-
#endif
13901372
override open func visit(_ node: LifetimeSpecifierArgumentSyntax) -> SyntaxVisitorContinueKind {
13911373
return visitAny(node._syntaxNode)
13921374
}
13931375

1394-
#if compiler(>=5.8)
13951376
@_spi(ExperimentalLanguageFeatures)
1396-
#endif
13971377
override open func visitPost(_ node: LifetimeSpecifierArgumentSyntax) {
13981378
visitAnyPost(node._syntaxNode)
13991379
}
14001380

1401-
#if compiler(>=5.8)
14021381
@_spi(ExperimentalLanguageFeatures)
1403-
#endif
14041382
override open func visit(_ node: LifetimeTypeSpecifierSyntax) -> SyntaxVisitorContinueKind {
14051383
return visitAny(node._syntaxNode)
14061384
}
14071385

1408-
#if compiler(>=5.8)
14091386
@_spi(ExperimentalLanguageFeatures)
1410-
#endif
14111387
override open func visitPost(_ node: LifetimeTypeSpecifierSyntax) {
14121388
visitAnyPost(node._syntaxNode)
14131389
}
@@ -2092,16 +2068,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
20922068
visitAnyPost(node._syntaxNode)
20932069
}
20942070

2095-
#if compiler(>=5.8)
20962071
@_spi(ExperimentalLanguageFeatures)
2097-
#endif
20982072
override open func visit(_ node: ThenStmtSyntax) -> SyntaxVisitorContinueKind {
20992073
return visitAny(node._syntaxNode)
21002074
}
21012075

2102-
#if compiler(>=5.8)
21032076
@_spi(ExperimentalLanguageFeatures)
2104-
#endif
21052077
override open func visitPost(_ node: ThenStmtSyntax) {
21062078
visitAnyPost(node._syntaxNode)
21072079
}
@@ -2282,16 +2254,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
22822254
visitAnyPost(node._syntaxNode)
22832255
}
22842256

2285-
#if compiler(>=5.8)
22862257
@_spi(ExperimentalLanguageFeatures)
2287-
#endif
22882258
override open func visit(_ node: UnsafeExprSyntax) -> SyntaxVisitorContinueKind {
22892259
return visitAny(node._syntaxNode)
22902260
}
22912261

2292-
#if compiler(>=5.8)
22932262
@_spi(ExperimentalLanguageFeatures)
2294-
#endif
22952263
override open func visitPost(_ node: UnsafeExprSyntax) {
22962264
visitAnyPost(node._syntaxNode)
22972265
}

Sources/SwiftSyntax/generated/SyntaxCollections.swift

-12
Original file line numberDiff line numberDiff line change
@@ -1048,9 +1048,7 @@ public struct LabeledExprListSyntax: SyntaxCollection, SyntaxHashable {
10481048
/// ### Contained in
10491049
///
10501050
/// - `LifetimeTypeSpecifierSyntax`.`LifetimeTypeSpecifierSyntax/arguments`
1051-
#if compiler(>=5.8)
10521051
@_spi(ExperimentalLanguageFeatures)
1053-
#endif
10541052
public struct LifetimeSpecifierArgumentListSyntax: SyntaxCollection, SyntaxHashable {
10551053
public typealias Element = LifetimeSpecifierArgumentSyntax
10561054

@@ -1925,9 +1923,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19251923
case simpleTypeSpecifier(SimpleTypeSpecifierSyntax)
19261924
/// A specifier that specifies function parameter on whose lifetime a type depends
19271925
/// - Note: Requires experimental feature `nonescapableTypes`.
1928-
#if compiler(>=5.8)
19291926
@_spi(ExperimentalLanguageFeatures)
1930-
#endif
19311927
case lifetimeTypeSpecifier(LifetimeTypeSpecifierSyntax)
19321928

19331929
public var _syntaxNode: Syntax {
@@ -1944,9 +1940,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19441940
}
19451941

19461942
/// - Note: Requires experimental feature `nonescapableTypes`.
1947-
#if compiler(>=5.8)
19481943
@_spi(ExperimentalLanguageFeatures)
1949-
#endif
19501944
public init(_ node: LifetimeTypeSpecifierSyntax) {
19511945
self = .lifetimeTypeSpecifier(node)
19521946
}
@@ -1991,9 +1985,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19911985
///
19921986
/// - Returns: `true` if the node can be cast, `false` otherwise.
19931987
/// - Note: Requires experimental feature `nonescapableTypes`.
1994-
#if compiler(>=5.8)
19951988
@_spi(ExperimentalLanguageFeatures)
1996-
#endif
19971989
public func `is`(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> Bool {
19981990
return self.as(syntaxType) != nil
19991991
}
@@ -2002,9 +1994,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
20021994
///
20031995
/// - Returns: An instance of `LifetimeTypeSpecifierSyntax`, or `nil` if the cast fails.
20041996
/// - Note: Requires experimental feature `nonescapableTypes`.
2005-
#if compiler(>=5.8)
20061997
@_spi(ExperimentalLanguageFeatures)
2007-
#endif
20081998
public func `as`(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> LifetimeTypeSpecifierSyntax? {
20091999
return LifetimeTypeSpecifierSyntax.init(self)
20102000
}
@@ -2014,9 +2004,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
20142004
/// - Returns: An instance of `LifetimeTypeSpecifierSyntax`.
20152005
/// - Warning: This function will crash if the cast is not possible. Use `as` to safely attempt a cast.
20162006
/// - Note: Requires experimental feature `nonescapableTypes`.
2017-
#if compiler(>=5.8)
20182007
@_spi(ExperimentalLanguageFeatures)
2019-
#endif
20202008
public func cast(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> LifetimeTypeSpecifierSyntax {
20212009
return self.as(LifetimeTypeSpecifierSyntax.self)!
20222010
}

0 commit comments

Comments
 (0)