Skip to content

Drop '#if compiler(>=5.8)' guards #2956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@ public struct KeywordSpec: IdentifierConvertible {
///
/// This is typically used to mark APIs as SPI when the keyword is part of an experimental language feature.
public var apiAttributes: AttributeListSyntax {
let attrList = AttributeListSyntax {
AttributeListSyntax {
if isExperimental {
let experimentalSPI: AttributeListSyntax = """
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
"""
experimentalSPI.with(\.trailingTrivia, .newline)
AttributeSyntax("@_spi(ExperimentalLanguageFeatures)")
.with(\.trailingTrivia, .newline)
}
}
return attrList.with(\.trailingTrivia, attrList.isEmpty ? [] : .newline)
}

/// Initializes a new `KeywordSpec` instance.
Expand Down
23 changes: 7 additions & 16 deletions CodeGeneration/Sources/SyntaxSupport/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,20 @@ public class Node: NodeChoiceConvertible {
/// Retrieve the attributes that should be printed on any API for the
/// generated node. If `forRaw` is true, this is for the raw syntax node.
public func apiAttributes(forRaw: Bool = false) -> AttributeListSyntax {
let attrList = AttributeListSyntax {
AttributeListSyntax {
if isExperimental {
// SPI for enum cases currently requires Swift 5.8 to work correctly.
let experimentalSPI: AttributeListSyntax = """
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
"""
experimentalSPI.with(\.trailingTrivia, .newline)
AttributeSyntax("@_spi(ExperimentalLanguageFeatures)")
.with(\.trailingTrivia, .newline)
}
if let spi = self.spi {
let spiAttr: AttributeListSyntax = """
#if compiler(>=5.8)
@_spi(\(spi))
#endif
"""
spiAttr.with(\.trailingTrivia, .newline)
AttributeSyntax("@_spi(\(spi))")
.with(\.trailingTrivia, .newline)
}
if forRaw {
"@_spi(RawSyntax)"
AttributeSyntax("@_spi(RawSyntax)")
.with(\.trailingTrivia, .newline)
}
}
return attrList.with(\.trailingTrivia, attrList.isEmpty ? [] : .newline)
}

public var apiAttributes: AttributeListSyntax {
Expand Down
16 changes: 0 additions & 16 deletions Sources/SwiftParser/generated/Parser+TokenSpecSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ extension AccessorDeclSyntax {
case mutableAddressWithOwner
case mutableAddressWithNativeOwner
case _read
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case read
case _modify
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case modify
case `init`

Expand Down Expand Up @@ -3085,14 +3081,10 @@ extension OptionalBindingConditionSyntax {
case `let`
case `var`
case `inout`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _mutating
case _borrowing
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _consuming

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
Expand Down Expand Up @@ -4049,14 +4041,10 @@ extension ValueBindingPatternSyntax {
case `let`
case `var`
case `inout`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _mutating
case _borrowing
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _consuming
case borrowing

Expand Down Expand Up @@ -4152,14 +4140,10 @@ extension VariableDeclSyntax {
case `let`
case `var`
case `inout`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _mutating
case _borrowing
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _consuming

init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
Expand Down
14 changes: 0 additions & 14 deletions Sources/SwiftSyntax/generated/Keyword.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case _Class
case _compilerInitialized
case _const
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _consuming
case _documentation
case _dynamicReplacement
Expand All @@ -40,9 +38,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case _local
case _modify
case _move
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case _mutating
case _NativeClass
case _NativeRefCountedObject
Expand Down Expand Up @@ -71,9 +67,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case _underlyingVersion
case _UnknownLayout
case _version
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case abi
case accesses
case actor
Expand Down Expand Up @@ -112,9 +106,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case `default`
case `defer`
case `deinit`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case dependsOn
case deprecated
case derivative
Expand Down Expand Up @@ -166,9 +158,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case macro
case message
case metadata
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case modify
case module
case mutableAddressWithNativeOwner
Expand Down Expand Up @@ -197,9 +187,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case `Protocol`
case `protocol`
case `public`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case read
case reasync
case renamed
Expand All @@ -211,9 +199,7 @@ public enum Keyword: UInt8, Hashable, Sendable {
case reverse
case right
case safe
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
case scoped
case `self`
case sending
Expand Down
32 changes: 0 additions & 32 deletions Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: ABIAttributeArgumentsSyntax) {
visitAnyPost(node._syntaxNode)
}
Expand Down Expand Up @@ -238,16 +234,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(Compiler)
#endif
override open func visitPost(_ node: AvailabilityMacroDefinitionSyntax) {
visitAnyPost(node._syntaxNode)
}
Expand Down Expand Up @@ -756,16 +748,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: DoExprSyntax) {
visitAnyPost(node._syntaxNode)
}
Expand Down Expand Up @@ -1370,44 +1358,32 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: LifetimeSpecifierArgumentListSyntax) {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: LifetimeSpecifierArgumentSyntax) {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: LifetimeTypeSpecifierSyntax) {
visitAnyPost(node._syntaxNode)
}
Expand Down Expand Up @@ -2092,16 +2068,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: ThenStmtSyntax) {
visitAnyPost(node._syntaxNode)
}
Expand Down Expand Up @@ -2282,16 +2254,12 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
visitAnyPost(node._syntaxNode)
}

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

#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
override open func visitPost(_ node: UnsafeExprSyntax) {
visitAnyPost(node._syntaxNode)
}
Expand Down
12 changes: 0 additions & 12 deletions Sources/SwiftSyntax/generated/SyntaxCollections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1048,9 +1048,7 @@ public struct LabeledExprListSyntax: SyntaxCollection, SyntaxHashable {
/// ### Contained in
///
/// - `LifetimeTypeSpecifierSyntax`.`LifetimeTypeSpecifierSyntax/arguments`
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
public struct LifetimeSpecifierArgumentListSyntax: SyntaxCollection, SyntaxHashable {
public typealias Element = LifetimeSpecifierArgumentSyntax

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

public var _syntaxNode: Syntax {
Expand All @@ -1944,9 +1940,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
}

/// - Note: Requires experimental feature `nonescapableTypes`.
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
public init(_ node: LifetimeTypeSpecifierSyntax) {
self = .lifetimeTypeSpecifier(node)
}
Expand Down Expand Up @@ -1991,9 +1985,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
///
/// - Returns: `true` if the node can be cast, `false` otherwise.
/// - Note: Requires experimental feature `nonescapableTypes`.
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
public func `is`(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> Bool {
return self.as(syntaxType) != nil
}
Expand All @@ -2002,9 +1994,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
///
/// - Returns: An instance of `LifetimeTypeSpecifierSyntax`, or `nil` if the cast fails.
/// - Note: Requires experimental feature `nonescapableTypes`.
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
public func `as`(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> LifetimeTypeSpecifierSyntax? {
return LifetimeTypeSpecifierSyntax.init(self)
}
Expand All @@ -2014,9 +2004,7 @@ public struct TypeSpecifierListSyntax: SyntaxCollection, SyntaxHashable {
/// - Returns: An instance of `LifetimeTypeSpecifierSyntax`.
/// - Warning: This function will crash if the cast is not possible. Use `as` to safely attempt a cast.
/// - Note: Requires experimental feature `nonescapableTypes`.
#if compiler(>=5.8)
@_spi(ExperimentalLanguageFeatures)
#endif
public func cast(_ syntaxType: LifetimeTypeSpecifierSyntax.Type) -> LifetimeTypeSpecifierSyntax {
return self.as(LifetimeTypeSpecifierSyntax.self)!
}
Expand Down
Loading