From 7458177b5113c8bc6c9889388fffb9e3ce8659bd Mon Sep 17 00:00:00 2001 From: Alexis Schultz Date: Wed, 29 Nov 2023 19:00:47 +0100 Subject: [PATCH] Add support for inout parameters to @DependencyEndpointMacro --- .../DependencyEndpointMacro.swift | 10 ++++- .../DependencyEndpointMacroTests.swift | 41 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Sources/DependenciesMacrosPlugin/DependencyEndpointMacro.swift b/Sources/DependenciesMacrosPlugin/DependencyEndpointMacro.swift index 7eb49add..332d997d 100644 --- a/Sources/DependenciesMacrosPlugin/DependencyEndpointMacro.swift +++ b/Sources/DependenciesMacrosPlugin/DependencyEndpointMacro.swift @@ -160,7 +160,15 @@ public enum DependencyEndpointMacro: AccessorMacro, PeerMacro { parameters[i].secondName = TokenSyntax(stringLiteral: "p\(offset)") parameters[i].colon = parameters[i].colon ?? .colonToken(trailingTrivia: .space) } - let appliedParameters = (0.. String = { _ in + "Hello, world" + } + } + """ + } expansion: { + """ + struct Blah { + public var doAThing: (_ a: inout Int, _ b: Int, _ c: inout Bool) -> String = { _ in + "Hello, world" + } { + @storageRestrictions(initializes: _doAThing) + init(initialValue) { + _doAThing = initialValue + } + get { + _doAThing + } + set { + _doAThing = newValue + } + } + + public func doAThing(a p0: inout Int, b p1: Int, c p2: inout Bool) -> String { + self.doAThing(&p0, p1, &p2) + } + + private var _doAThing: (_ a: inout Int, _ b: Int, _ c: inout Bool) -> String = { _ in + XCTestDynamicOverlay.XCTFail("Unimplemented: 'doAThing'") + return "Hello, world" + } + } + """ + } + } }