Skip to content

Commit 3e12a40

Browse files
committed
Drop '#if compiler(>=5.8)' guards
swift-syntax does not support pre-5.8 compilers anymore. `#if compiler(>=5.8)` guards are meaningless.
1 parent af26da4 commit 3e12a40

19 files changed

+8
-196
lines changed

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

Lines changed: 3 additions & 8 deletions
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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,16 @@ public class Node: NodeChoiceConvertible {
9393
/// Retrieve the attributes that should be printed on any API for the
9494
/// generated node. If `forRaw` is true, this is for the raw syntax node.
9595
public func apiAttributes(forRaw: Bool = false) -> AttributeListSyntax {
96-
let attrList = AttributeListSyntax {
96+
AttributeListSyntax {
9797
if isExperimental {
98-
// SPI for enum cases currently requires Swift 5.8 to work correctly.
99-
let experimentalSPI: AttributeListSyntax = """
100-
#if compiler(>=5.8)
101-
@_spi(ExperimentalLanguageFeatures)
102-
#endif
103-
"""
104-
experimentalSPI.with(\.trailingTrivia, .newline)
98+
AttributeSyntax("@_spi(ExperimentalLanguageFeatures)")
99+
.with(\.trailingTrivia, .newline)
105100
}
106101
if forRaw {
107-
"@_spi(RawSyntax)"
102+
AttributeSyntax("@_spi(RawSyntax)")
103+
.with(\.trailingTrivia, .newline)
108104
}
109105
}
110-
return attrList.with(\.trailingTrivia, attrList.isEmpty ? [] : .newline)
111106
}
112107

113108
public var apiAttributes: AttributeListSyntax {

Sources/SwiftParser/generated/Parser+TokenSpecSet.swift

Lines changed: 0 additions & 16 deletions
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

Lines changed: 0 additions & 14 deletions
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

Lines changed: 0 additions & 28 deletions
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
}
@@ -742,16 +738,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
742738
visitAnyPost(node._syntaxNode)
743739
}
744740

745-
#if compiler(>=5.8)
746741
@_spi(ExperimentalLanguageFeatures)
747-
#endif
748742
override open func visit(_ node: DoExprSyntax) -> SyntaxVisitorContinueKind {
749743
return visitAny(node._syntaxNode)
750744
}
751745

752-
#if compiler(>=5.8)
753746
@_spi(ExperimentalLanguageFeatures)
754-
#endif
755747
override open func visitPost(_ node: DoExprSyntax) {
756748
visitAnyPost(node._syntaxNode)
757749
}
@@ -1356,44 +1348,32 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
13561348
visitAnyPost(node._syntaxNode)
13571349
}
13581350

1359-
#if compiler(>=5.8)
13601351
@_spi(ExperimentalLanguageFeatures)
1361-
#endif
13621352
override open func visit(_ node: LifetimeSpecifierArgumentListSyntax) -> SyntaxVisitorContinueKind {
13631353
return visitAny(node._syntaxNode)
13641354
}
13651355

1366-
#if compiler(>=5.8)
13671356
@_spi(ExperimentalLanguageFeatures)
1368-
#endif
13691357
override open func visitPost(_ node: LifetimeSpecifierArgumentListSyntax) {
13701358
visitAnyPost(node._syntaxNode)
13711359
}
13721360

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

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

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

1394-
#if compiler(>=5.8)
13951376
@_spi(ExperimentalLanguageFeatures)
1396-
#endif
13971377
override open func visitPost(_ node: LifetimeTypeSpecifierSyntax) {
13981378
visitAnyPost(node._syntaxNode)
13991379
}
@@ -2078,16 +2058,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
20782058
visitAnyPost(node._syntaxNode)
20792059
}
20802060

2081-
#if compiler(>=5.8)
20822061
@_spi(ExperimentalLanguageFeatures)
2083-
#endif
20842062
override open func visit(_ node: ThenStmtSyntax) -> SyntaxVisitorContinueKind {
20852063
return visitAny(node._syntaxNode)
20862064
}
20872065

2088-
#if compiler(>=5.8)
20892066
@_spi(ExperimentalLanguageFeatures)
2090-
#endif
20912067
override open func visitPost(_ node: ThenStmtSyntax) {
20922068
visitAnyPost(node._syntaxNode)
20932069
}
@@ -2268,16 +2244,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
22682244
visitAnyPost(node._syntaxNode)
22692245
}
22702246

2271-
#if compiler(>=5.8)
22722247
@_spi(ExperimentalLanguageFeatures)
2273-
#endif
22742248
override open func visit(_ node: UnsafeExprSyntax) -> SyntaxVisitorContinueKind {
22752249
return visitAny(node._syntaxNode)
22762250
}
22772251

2278-
#if compiler(>=5.8)
22792252
@_spi(ExperimentalLanguageFeatures)
2280-
#endif
22812253
override open func visitPost(_ node: UnsafeExprSyntax) {
22822254
visitAnyPost(node._syntaxNode)
22832255
}

Sources/SwiftSyntax/generated/SyntaxCollections.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,7 @@ public struct LabeledExprListSyntax: SyntaxCollection, SyntaxHashable {
10441044
/// ### Children
10451045
///
10461046
/// `LifetimeSpecifierArgumentSyntax` `*`
1047-
#if compiler(>=5.8)
10481047
@_spi(ExperimentalLanguageFeatures)
1049-
#endif
10501048
public struct LifetimeSpecifierArgumentListSyntax: SyntaxCollection, SyntaxHashable {
10511049
public typealias Element = LifetimeSpecifierArgumentSyntax
10521050

@@ -1921,9 +1919,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19211919
case simpleTypeSpecifier(SimpleTypeSpecifierSyntax)
19221920
/// A specifier that specifies function parameter on whose lifetime a type depends
19231921
/// - Note: Requires experimental feature `nonescapableTypes`.
1924-
#if compiler(>=5.8)
19251922
@_spi(ExperimentalLanguageFeatures)
1926-
#endif
19271923
case lifetimeTypeSpecifier(LifetimeTypeSpecifierSyntax)
19281924

19291925
public var _syntaxNode: Syntax {
@@ -1940,9 +1936,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19401936
}
19411937

19421938
/// - Note: Requires experimental feature `nonescapableTypes`.
1943-
#if compiler(>=5.8)
19441939
@_spi(ExperimentalLanguageFeatures)
1945-
#endif
19461940
public init(_ node: LifetimeTypeSpecifierSyntax) {
19471941
self = .lifetimeTypeSpecifier(node)
19481942
}
@@ -1987,9 +1981,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19871981
///
19881982
/// - Returns: `true` if the node can be cast, `false` otherwise.
19891983
/// - Note: Requires experimental feature `nonescapableTypes`.
1990-
#if compiler(>=5.8)
19911984
@_spi(ExperimentalLanguageFeatures)
1992-
#endif
19931985
public func `is`(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> Bool {
19941986
return self.as(syntaxType) != nil
19951987
}
@@ -1998,9 +1990,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
19981990
///
19991991
/// - Returns: An instance of `LifetimeTypeSpecifierSyntax`, or `nil` if the cast fails.
20001992
/// - Note: Requires experimental feature `nonescapableTypes`.
2001-
#if compiler(>=5.8)
20021993
@_spi(ExperimentalLanguageFeatures)
2003-
#endif
20041994
public func `as`(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> LifetimeTypeSpecifierSyntax? {
20051995
return LifetimeTypeSpecifierSyntax.init(self)
20061996
}
@@ -2010,9 +2000,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
20102000
/// - Returns: An instance of `LifetimeTypeSpecifierSyntax`.
20112001
/// - Warning: This function will crash if the cast is not possible. Use `as` to safely attempt a cast.
20122002
/// - Note: Requires experimental feature `nonescapableTypes`.
2013-
#if compiler(>=5.8)
20142003
@_spi(ExperimentalLanguageFeatures)
2015-
#endif
20162004
public func cast(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> LifetimeTypeSpecifierSyntax {
20172005
return self.as(LifetimeTypeSpecifierSyntax.self)!
20182006
}

0 commit comments

Comments
 (0)