Skip to content

Commit 93e238f

Browse files
committed
Require Swift 5.8 for SPI experimental feature syntax nodes
Swift versions prior to 5.8 did not correctly handle SPI enum cases, so avoid marking experimental feature nodes SPI if building with such a compiler.
1 parent d39d425 commit 93e238f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

CodeGeneration/Sources/SyntaxSupport/Node.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ public class Node {
9898
public func apiAttributes(forRaw: Bool = false) -> AttributeListSyntax {
9999
let attrList = AttributeListSyntax {
100100
if isExperimental {
101-
"@_spi(ExperimentalLanguageFeatures)"
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)
102108
}
103109
if forRaw {
104110
"@_spi(RawSyntax)"

0 commit comments

Comments
 (0)