Skip to content

Commit 445ef28

Browse files
committed
Minor cleanup from if to guard statement
I think the guard is a lot easier to read here, noticed while reviewing #3171.
1 parent bcb9e00 commit 445ef28

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/SwiftParser/Lookahead.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ extension Parser.Lookahead {
266266
}
267267

268268
// If we don't have attributes, then it cannot be an accessor block.
269-
if nextToken.rawTokenKind != .atSign {
269+
guard self.peek(isAt: .atSign) else {
270270
return false
271271
}
272272

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,4 +3831,16 @@ final class UsingDeclarationTests: ParserTestCase {
38313831
)
38323832
)
38333833
}
3834+
3835+
func testAccessorBlockAfterPatternBindingDeclWithAttribute() {
3836+
assertParse(
3837+
"""
3838+
var x: Int = foo()
3839+
{
3840+
@available(*, deprecated)
3841+
didSet {}
3842+
}
3843+
"""
3844+
)
3845+
}
38343846
}

0 commit comments

Comments
 (0)