Skip to content

Commit 793ccbd

Browse files
committed
Revert attribute changes
1 parent 462f819 commit 793ccbd

File tree

5 files changed

+24
-86
lines changed

5 files changed

+24
-86
lines changed

Sources/SwiftParser/Attributes.swift

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ extension Parser {
362362
let additionalArgs = self.parseArgumentListElements(
363363
pattern: .none,
364364
flavor: .attributeArguments,
365-
allowTrailingComma: true
365+
allowTrailingComma: false
366366
)
367367
return [roleElement] + additionalArgs
368368
}
@@ -852,11 +852,6 @@ extension Parser {
852852
arena: self.arena
853853
)
854854
)
855-
856-
// If this was a trailing closure then there are no more elements
857-
if self.at(.rightParen) {
858-
break
859-
}
860855
} while keepGoing != nil
861856
return RawBackDeployedAttributeArgumentsSyntax(
862857
unexpectedBeforeLabel,
@@ -888,11 +883,6 @@ extension Parser {
888883
arena: self.arena
889884
)
890885
)
891-
892-
// If this was a trailing closure then there are no more elements
893-
if self.at(.rightParen) {
894-
break
895-
}
896886
} while keepGoing != nil
897887

898888
return RawOriginallyDefinedInAttributeArgumentsSyntax(
@@ -1011,11 +1001,6 @@ extension Parser {
10111001
arena: self.arena
10121002
)
10131003
)
1014-
1015-
// If this was a trailing closure then there are no more elements
1016-
if self.at(.rightParen) {
1017-
break
1018-
}
10191004
} while keepGoing != nil
10201005

10211006
return RawDocumentationAttributeArgumentListSyntax(elements: arguments, arena: self.arena)

Sources/SwiftParser/Availability.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ extension Parser {
4747
arena: self.arena
4848
)
4949
)
50-
51-
// If this was a trailing closure, there are no more elements
52-
if self.at(.rightParen) {
53-
break
54-
}
5550
} while keepGoing != nil
5651
&& self.hasProgressed(&availabilityArgumentProgress)
5752
}

Tests/SwiftParserTest/AttributeTests.swift

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -470,31 +470,13 @@ final class AttributeTests: ParserTestCase {
470470
"""
471471
)
472472

473-
assertParse(
474-
"""
475-
@backDeployed(
476-
before: macOS 12.0,
477-
)
478-
struct Foo {}
479-
"""
480-
)
481-
482473
assertParse(
483474
"""
484475
@backDeployed(before: macos 12.0, iOS 15.0)
485476
struct Foo {}
486477
"""
487478
)
488479

489-
assertParse(
490-
"""
491-
@backDeployed(
492-
before: macos 12.0,
493-
iOS 15.0,)
494-
struct Foo {}
495-
"""
496-
)
497-
498480
assertParse(
499481
"""
500482
@available(macOS 11.0, *)
@@ -555,16 +537,6 @@ final class AttributeTests: ParserTestCase {
555537
"""
556538
)
557539

558-
assertParse(
559-
"""
560-
@_originallyDefinedIn(
561-
module: "ToasterKit",
562-
macOS 10.15,
563-
)
564-
struct Vehicle {}
565-
"""
566-
)
567-
568540
assertParse(
569541
"""
570542
@_originallyDefinedIn(module: "ToasterKit", macOS 10.15, iOS 13)
@@ -874,26 +846,6 @@ final class AttributeTests: ParserTestCase {
874846
}
875847
"""
876848
)
877-
878-
assertParse(
879-
"""
880-
@attached(
881-
member,
882-
names: named(deinit),
883-
)
884-
macro m()
885-
"""
886-
)
887-
888-
assertParse(
889-
"""
890-
@attached(
891-
extension,
892-
conformances: P1, P2,
893-
)
894-
macro AddAllConformances()
895-
"""
896-
)
897849
}
898850

899851
func testAttachedExtensionAttribute() {

Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,17 @@ final class AvailabilityQueryTests: ParserTestCase {
400400
"""
401401
if #available(OSX 10.51,1️⃣) {
402402
}
403-
"""
403+
""",
404+
diagnostics: [
405+
DiagnosticSpec(
406+
message: "expected version restriction in availability argument",
407+
fixIts: ["insert version restriction"]
408+
)
409+
],
410+
fixedSource: """
411+
if #available(OSX 10.51, <#identifier#>) {
412+
}
413+
"""
404414
)
405415
}
406416

Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,19 @@ final class AvailabilityQueryUnavailabilityTests: ParserTestCase {
381381
func testAvailabilityQueryUnavailability23() {
382382
assertParse(
383383
"""
384-
if #unavailable(OSX 10.51,) {
384+
if #unavailable(OSX 10.51,1️⃣) {
385385
}
386-
"""
386+
""",
387+
diagnostics: [
388+
DiagnosticSpec(
389+
message: "expected version restriction in availability argument",
390+
fixIts: ["insert version restriction"]
391+
)
392+
],
393+
fixedSource: """
394+
if #unavailable(OSX 10.51, <#identifier#>) {
395+
}
396+
"""
387397
)
388398
}
389399

@@ -601,18 +611,4 @@ final class AvailabilityQueryUnavailabilityTests: ParserTestCase {
601611
]
602612
)
603613
}
604-
605-
func testTrailingComma() {
606-
assertParse(
607-
"""
608-
func fooDeprecated() {
609-
if #available(
610-
iOS 18.0,
611-
macOS 14.0,
612-
*,
613-
) {}
614-
}
615-
"""
616-
)
617-
}
618614
}

0 commit comments

Comments
 (0)