Skip to content

Commit 0380bd5

Browse files
committed
Parse Qualified Attribute Names Correctly
1 parent 3bf88ba commit 0380bd5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Sources/SwiftParser/Lookahead.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,14 @@ extension Parser.Lookahead {
178178
}
179179

180180
while let _ = self.consume(if: .atSign) {
181-
self.expectIdentifierOrRethrowsWithoutRecovery()
181+
// Consume qualified names that may or may not involve generic arguments.
182+
repeat {
183+
self.expectIdentifierOrRethrowsWithoutRecovery()
184+
// We don't care whether this succeeds or fails to eat generic
185+
// parameters.
186+
_ = self.consumeGenericArguments()
187+
} while self.consume(if: .period) != nil
188+
182189
if self.consume(if: .leftParen) != nil {
183190
while !self.at(any: [.eof, .rightParen, .poundEndifKeyword]) {
184191
self.skipSingle()

Tests/SwiftParserTest/Attributes.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,11 @@ final class AttributeTests: XCTestCase {
9696
"""
9797
)
9898
}
99+
100+
func testQualifiedAttribute() {
101+
AssertParse(
102+
"""
103+
@_Concurrency.MainActor(unsafe) public struct Image : SwiftUI.View {}
104+
""")
105+
}
99106
}

0 commit comments

Comments
 (0)