@@ -23,6 +23,7 @@ private extension AsyncWithoutAwaitRule {
2323
2424 final class Visitor : ViolationsSyntaxVisitor < ConfigurationType > {
2525 private var functionScopes = Stack < FuncInfo > ( )
26+ private var actorTypeStack = Stack < Bool > ( )
2627 private var pendingAsync : TokenSyntax ?
2728
2829 override func visit( _ node: FunctionDeclSyntax ) -> SyntaxVisitorContinueKind {
@@ -72,7 +73,9 @@ private extension AsyncWithoutAwaitRule {
7273
7374 override func visit( _ node: InitializerDeclSyntax ) -> SyntaxVisitorContinueKind {
7475 if node. body != nil {
75- let asyncToken = node. needsToKeepAsync ? nil : node. signature. effectSpecifiers? . asyncSpecifier
76+ let asyncToken = node. needsToKeepAsync || actorTypeStack. peek ( ) == true
77+ ? nil
78+ : node. signature. effectSpecifiers? . asyncSpecifier
7679 functionScopes. push ( . init( asyncToken: asyncToken) )
7780 }
7881 return . visitChildren
@@ -113,6 +116,42 @@ private extension AsyncWithoutAwaitRule {
113116 }
114117 }
115118
119+ override func visit( _: ActorDeclSyntax ) -> SyntaxVisitorContinueKind {
120+ actorTypeStack. push ( true )
121+ return . visitChildren
122+ }
123+
124+ override func visitPost( _: ActorDeclSyntax ) {
125+ actorTypeStack. pop ( )
126+ }
127+
128+ override func visit( _: ClassDeclSyntax ) -> SyntaxVisitorContinueKind {
129+ actorTypeStack. push ( false )
130+ return . visitChildren
131+ }
132+
133+ override func visitPost( _: ClassDeclSyntax ) {
134+ actorTypeStack. pop ( )
135+ }
136+
137+ override func visit( _: EnumDeclSyntax ) -> SyntaxVisitorContinueKind {
138+ actorTypeStack. push ( false )
139+ return . visitChildren
140+ }
141+
142+ override func visitPost( _: EnumDeclSyntax ) {
143+ actorTypeStack. pop ( )
144+ }
145+
146+ override func visit( _: StructDeclSyntax ) -> SyntaxVisitorContinueKind {
147+ actorTypeStack. push ( false )
148+ return . visitChildren
149+ }
150+
151+ override func visitPost( _: StructDeclSyntax ) {
152+ actorTypeStack. pop ( )
153+ }
154+
116155 override func visit( _: FunctionParameterSyntax ) -> SyntaxVisitorContinueKind {
117156 . skipChildren
118157 }
0 commit comments