Skip to content

Commit 10825a7

Browse files
committed
Handle 'reasync' In Function Signatures
1 parent 58b985a commit 10825a7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,14 @@ extension Parser {
14121412
public mutating func parseFunctionSignature() -> RawFunctionSignatureSyntax {
14131413
let input = self.parseParameterClause(for: .functionParameters)
14141414

1415-
let async = self.consumeIfContextualKeyword("async")
1415+
let async: RawTokenSyntax?
1416+
if let asyncTok = self.consumeIfContextualKeyword("async") {
1417+
async = asyncTok
1418+
} else if let reasync = self.consumeIfContextualKeyword("reasync") {
1419+
async = reasync
1420+
} else {
1421+
async = nil
1422+
}
14161423

14171424
var throwsKeyword = self.consume(ifAny: [.throwsKeyword, .rethrowsKeyword])
14181425

Tests/SwiftParserTest/Declarations.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,21 @@ final class DeclarationTests: XCTestCase {
10051005
func isolatedConst(isolated _const: String) {}
10061006
"""#)
10071007
}
1008+
1009+
func testReasyncFunctions() throws {
1010+
AssertParse(
1011+
"""
1012+
class MyType {
1013+
init(_ f: () async -> Void) reasync {
1014+
await f()
1015+
}
1016+
1017+
func foo(index: Int) reasync rethrows -> String {
1018+
await f()
1019+
}
1020+
}
1021+
""")
1022+
}
10081023
}
10091024

10101025
extension Parser.DeclAttributes {

0 commit comments

Comments
 (0)