Skip to content

Commit 6deb1ff

Browse files
committed
[Parser] Remove abiAttribute experimental feature
But `ABIAttributeArgumentsSyntax` is still under `@_spi(ExperimentalLanguageFeatures)`. Not parsing the interior of `@abi` attribute causes catastrophic breakage to the tree. Having "unknown" syntax kind in the tree is better than dealing with structually broken trees.
1 parent d9fabf7 commit 6deb1ff

File tree

4 files changed

+30
-66
lines changed

4 files changed

+30
-66
lines changed

CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public enum ExperimentalFeature: String, CaseIterable {
2020
case trailingComma
2121
case coroutineAccessors
2222
case valueGenerics
23-
case abiAttribute
2423
case keypathWithMethodMembers
2524
case oldOwnershipOperatorSpellings
2625

@@ -41,8 +40,6 @@ public enum ExperimentalFeature: String, CaseIterable {
4140
return "CoroutineAccessors"
4241
case .valueGenerics:
4342
return "ValueGenerics"
44-
case .abiAttribute:
45-
return "ABIAttribute"
4643
case .keypathWithMethodMembers:
4744
return "KeypathWithMethodMembers"
4845
case .oldOwnershipOperatorSpellings:
@@ -67,8 +64,6 @@ public enum ExperimentalFeature: String, CaseIterable {
6764
return "coroutine accessors"
6865
case .valueGenerics:
6966
return "value generics"
70-
case .abiAttribute:
71-
return "@abi attribute"
7267
case .keypathWithMethodMembers:
7368
return "keypaths with method members"
7469
case .oldOwnershipOperatorSpellings:

Sources/SwiftParser/Attributes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ extension Parser {
9696
case TokenSpec(._typeEraser): self = ._typeEraser
9797
case TokenSpec(._unavailableFromAsync): self = ._unavailableFromAsync
9898
case TokenSpec(.`rethrows`): self = .rethrows
99-
case TokenSpec(.abi) where experimentalFeatures.contains(.abiAttribute): self = .abi
99+
case TokenSpec(.abi): self = .abi
100100
case TokenSpec(.attached): self = .attached
101101
case TokenSpec(.available): self = .available
102102
case TokenSpec(.backDeployed): self = .backDeployed

Sources/SwiftParser/generated/ExperimentalFeatures.swift

Lines changed: 2 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/SwiftParserTest/AttributeTests.swift

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,73 +1008,64 @@ final class AttributeTests: ParserTestCase {
10081008
returnClause: ReturnClauseSyntax(type: TypeSyntax("Int"))
10091009
)
10101010
) {},
1011-
experimentalFeatures: [.abiAttribute]
1011+
experimentalFeatures: []
10121012
)
10131013

10141014
assertParse(
10151015
"""
10161016
@abi(associatedtype AssocTy)
10171017
associatedtype AssocTy
1018-
""",
1019-
experimentalFeatures: [.abiAttribute]
1018+
"""
10201019
)
10211020
assertParse(
10221021
"""
10231022
@abi(deinit)
10241023
deinit {}
1025-
""",
1026-
experimentalFeatures: [.abiAttribute]
1024+
"""
10271025
)
10281026
assertParse(
10291027
"""
10301028
enum EnumCaseDeclNotParsedAtTopLevel {
10311029
@abi(case someCase)
10321030
case someCase
10331031
}
1034-
""",
1035-
experimentalFeatures: [.abiAttribute]
1032+
"""
10361033
)
10371034
assertParse(
10381035
"""
10391036
@abi(func fn())
10401037
func fn()
1041-
""",
1042-
experimentalFeatures: [.abiAttribute]
1038+
"""
10431039
)
10441040
assertParse(
10451041
"""
10461042
@abi(init())
10471043
init() {}
1048-
""",
1049-
experimentalFeatures: [.abiAttribute]
1044+
"""
10501045
)
10511046
assertParse(
10521047
"""
10531048
@abi(subscript(i: Int) -> Element)
10541049
subscript(i: Int) -> Element {}
1055-
""",
1056-
experimentalFeatures: [.abiAttribute]
1050+
"""
10571051
)
10581052
assertParse(
10591053
"""
10601054
@abi(typealias Typealias = @escaping () -> Void)
10611055
typealias Typealias = () -> Void
1062-
""",
1063-
experimentalFeatures: [.abiAttribute]
1056+
"""
10641057
)
10651058
assertParse(
10661059
"""
10671060
@abi(let c1, c2)
10681061
let c1, c2
1069-
""",
1070-
experimentalFeatures: [.abiAttribute]
1062+
"""
10711063
)
10721064
assertParse(
10731065
"""
10741066
@abi(var v1, v2)
10751067
var v1, v2
1076-
""",
1077-
experimentalFeatures: [.abiAttribute]
1068+
"""
10781069
)
10791070

10801071
assertParse(
@@ -1089,8 +1080,7 @@ final class AttributeTests: ParserTestCase {
10891080
),
10901081
diagnostics: [
10911082
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file")
1092-
],
1093-
experimentalFeatures: [.abiAttribute]
1083+
]
10941084
)
10951085

10961086
assertParse(
@@ -1114,8 +1104,7 @@ final class AttributeTests: ParserTestCase {
11141104
),
11151105
diagnostics: [
11161106
DiagnosticSpec(locationMarker: "1️⃣", message: "import is not permitted as ABI-providing declaration")
1117-
],
1118-
experimentalFeatures: [.abiAttribute]
1107+
]
11191108
)
11201109

11211110
//
@@ -1126,66 +1115,57 @@ final class AttributeTests: ParserTestCase {
11261115
"""
11271116
@abi(associatedtype AssocTy = T)
11281117
associatedtype AssocTy
1129-
""",
1130-
experimentalFeatures: [.abiAttribute]
1118+
"""
11311119
)
11321120
assertParse(
11331121
"""
11341122
@abi(deinit {})
11351123
deinit {}
1136-
""",
1137-
experimentalFeatures: [.abiAttribute]
1124+
"""
11381125
)
11391126
assertParse(
11401127
"""
11411128
enum EnumCaseDeclNotParsedAtTopLevel {
11421129
@abi(case someCase = 42)
11431130
case someCase
11441131
}
1145-
""",
1146-
experimentalFeatures: [.abiAttribute]
1132+
"""
11471133
)
11481134
assertParse(
11491135
"""
11501136
@abi(func fn() {})
11511137
func fn()
1152-
""",
1153-
experimentalFeatures: [.abiAttribute]
1138+
"""
11541139
)
11551140
assertParse(
11561141
"""
11571142
@abi(init() {})
11581143
init() {}
1159-
""",
1160-
experimentalFeatures: [.abiAttribute]
1144+
"""
11611145
)
11621146
assertParse(
11631147
"""
11641148
@abi(subscript(i: Int) -> Element { get {} set {} })
11651149
subscript(i: Int) -> Element {}
1166-
""",
1167-
experimentalFeatures: [.abiAttribute]
1150+
"""
11681151
)
11691152
assertParse(
11701153
"""
11711154
@abi(let c1 = 1, c2 = 2)
11721155
let c1, c2
1173-
""",
1174-
experimentalFeatures: [.abiAttribute]
1156+
"""
11751157
)
11761158
assertParse(
11771159
"""
11781160
@abi(var v1 = 1, v2 = 2)
11791161
var v1, v2
1180-
""",
1181-
experimentalFeatures: [.abiAttribute]
1162+
"""
11821163
)
11831164
assertParse(
11841165
"""
11851166
@abi(var v3 { get {} set {} })
11861167
var v3
1187-
""",
1188-
experimentalFeatures: [.abiAttribute]
1168+
"""
11891169
)
11901170

11911171
//
@@ -1207,8 +1187,7 @@ final class AttributeTests: ParserTestCase {
12071187
fixedSource: """
12081188
@abi(var <#pattern#>)
12091189
var v1
1210-
""",
1211-
experimentalFeatures: [.abiAttribute]
1190+
"""
12121191
)
12131192
assertParse(
12141193
"""
@@ -1231,8 +1210,7 @@ final class AttributeTests: ParserTestCase {
12311210
fixedSource: """
12321211
@abi(var v2)
12331212
var v2
1234-
""",
1235-
experimentalFeatures: [.abiAttribute]
1213+
"""
12361214
)
12371215
assertParse(
12381216
"""
@@ -1250,8 +1228,7 @@ final class AttributeTests: ParserTestCase {
12501228
fixedSource: """
12511229
@abi(<#declaration#>)
12521230
func fn2() {}
1253-
""",
1254-
experimentalFeatures: [.abiAttribute]
1231+
"""
12551232
)
12561233
assertParse(
12571234
"""
@@ -1268,8 +1245,7 @@ final class AttributeTests: ParserTestCase {
12681245
fixedSource: """
12691246
@abi(<#declaration#>)
12701247
func fn3() {}
1271-
""",
1272-
experimentalFeatures: [.abiAttribute]
1248+
"""
12731249
)
12741250
assertParse(
12751251
"""
@@ -1291,8 +1267,7 @@ final class AttributeTests: ParserTestCase {
12911267
fixedSource: """
12921268
@abi(<#declaration#>) func fn4_abi())
12931269
func fn4() {}
1294-
""",
1295-
experimentalFeatures: [.abiAttribute]
1270+
"""
12961271
)
12971272

12981273
// `#if` is banned inside an `@abi` attribute.
@@ -1325,8 +1300,7 @@ final class AttributeTests: ParserTestCase {
13251300
func _fn<E: Error>() throws(E)
13261301
)
13271302
func fn<E: Error>() throws(E) {}
1328-
""",
1329-
experimentalFeatures: [.abiAttribute]
1303+
"""
13301304
)
13311305
}
13321306

0 commit comments

Comments
 (0)