File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 13
13
@_spi ( RawSyntax) import SwiftSyntax
14
14
15
15
extension TokenConsumer {
16
- func atStartOfDeclaration( isAtTopLevel: Bool = false , allowRecovery: Bool = false ) -> Bool {
16
+ func atStartOfDeclaration(
17
+ isAtTopLevel: Bool = false ,
18
+ allowRecovery: Bool = false
19
+ ) -> Bool {
17
20
if self . at ( anyIn: PoundDeclarationStart . self) != nil {
18
21
return true
19
22
}
@@ -54,6 +57,19 @@ extension TokenConsumer {
54
57
declStartKeyword = subparser. at ( anyIn: DeclarationStart . self) ? . 0
55
58
}
56
59
switch declStartKeyword {
60
+ case . actorContextualKeyword:
61
+ // actor Foo {}
62
+ if subparser. peek ( ) . tokenKind == . identifier {
63
+ return true
64
+ }
65
+ // actor may be somewhere in the modifier list. Eat the tokens until we get
66
+ // to something that isn't the start of a decl. If that is an identifier,
67
+ // it's an actor declaration, otherwise, it isn't.
68
+ var lookahead = subparser. lookahead ( )
69
+ repeat {
70
+ lookahead. consumeAnyToken ( )
71
+ } while lookahead. atStartOfDeclaration ( )
72
+ return lookahead. at ( . identifier)
57
73
case . caseKeyword, nil :
58
74
// When 'case' appears inside a function, it's probably a switch
59
75
// case, not an enum case declaration.
Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ final class StatementTests: XCTestCase {
91
91
}
92
92
93
93
func testReturn( ) {
94
+ AssertParse ( " return actor " , { $0. parseReturnStatement ( ) } )
95
+
94
96
AssertParse ( " { #^ASYNC^#return 0 } " ,
95
97
{ $0. parseClosureExpression ( ) } ,
96
98
substructure: Syntax ( ReturnStmtSyntax ( returnKeyword: . returnKeyword( ) ,
You can’t perform that action at this time.
0 commit comments