File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
Sources/SpyableMacro/Factories
Tests/SpyableMacroTests/Factories Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -203,16 +203,9 @@ struct ClosureFactory {
203203
204204extension FunctionParameterListSyntax . Element {
205205 fileprivate var isInoutParameter : Bool {
206- guard let attributedType = self . type. as ( AttributedTypeSyntax . self) else {
207- return false
208- }
209-
210- #if canImport(SwiftSyntax600)
211- let specifier = attributedType. specifiers. first? . firstToken ( viewMode: . all) ? . text
212- #else
213- let specifier = attributedType. specifier? . text
214- #endif
215-
216- return specifier == TokenSyntax . keyword ( . inout) . text
206+ // Check if the type contains 'inout' anywhere in its description
207+ // This works regardless of SwiftSyntax version and handles cases like "isolated inout"
208+ let typeDescription = self . type. description. trimmingCharacters ( in: . whitespacesAndNewlines)
209+ return typeDescription. contains ( " inout " )
217210 }
218211}
Original file line number Diff line number Diff line change @@ -55,6 +55,14 @@ final class UT_ClosureFactory: XCTestCase {
5555 )
5656 }
5757
58+ func testVariableDeclarationWithIsolatedInoutAttribute( ) throws {
59+ try assertProtocolFunction (
60+ withFunctionDeclaration: " func _ignore_(value: isolated inout TestActor) " ,
61+ prefixForVariable: " _prefix_ " ,
62+ expectingVariableDeclaration: " var _prefix_Closure: ((isolated inout TestActor) -> Void)? "
63+ )
64+ }
65+
5866 func testVariableDeclarationWithGenericParameter( ) throws {
5967 try assertProtocolFunction (
6068 withFunctionDeclaration: " func _ignore_<T>(value: T) " ,
@@ -133,6 +141,14 @@ final class UT_ClosureFactory: XCTestCase {
133141 )
134142 }
135143
144+ func testCallExpressionWithIsolatedInoutAttribute( ) throws {
145+ try assertProtocolFunction (
146+ withFunctionDeclaration: " func _ignore_(value: isolated inout TestActor) " ,
147+ prefixForVariable: " _prefix_ " ,
148+ expectingCallExpression: " _prefix_Closure?(&value) "
149+ )
150+ }
151+
136152 func testCallExpressionWithGenericParameter( ) throws {
137153 try assertProtocolFunction (
138154 withFunctionDeclaration: " func _ignore_<T>(value: T) " ,
You can’t perform that action at this time.
0 commit comments