diff --git a/README.md b/README.md index 856e022..e9f50ed 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ try #swizzle(UIViewController.viewDidLoad) { $self in print("After") } -try #swizzle(UIViewController.viewDidAppear, param: Bool.self) { $self, animated in +try #swizzle(UIViewController.viewDidAppear, params: Bool.self) { $self, animated in print("Before") self.viewDidAppear(animated) print("After") diff --git a/Sources/Swizzling/Macros.swift b/Sources/Swizzling/Macros.swift index 82877ff..9316b15 100644 --- a/Sources/Swizzling/Macros.swift +++ b/Sources/Swizzling/Macros.swift @@ -20,19 +20,7 @@ public macro swizzle( // MARK: Functions - Non Returning -// NOTE: this is only needed because some weird behavior in the compiler causes the variadic -// version below to throw a false positive error when passing a single param under very specific -// conditions. This version is a workaround that can be used in those cases. -// -// Reproducible case: -// ```swift -// try #swizzle( -// SUT.functionWithParamsWithoutReturn, -// params: Int.self -// ) { $self, state in -// self.functionWithParamsWithoutReturn(state) // 🛑 error: Cannot pass value pack expansion to non-pack parameter of type 'Int' -// } -// ``` +@available(*, deprecated, renamed: "swizzle(_:params:implementation:)") @discardableResult @freestanding(expression) public macro swizzle( @@ -51,19 +39,7 @@ public macro swizzle( // MARK: Functions - Returning -// NOTE: this is only needed because some weird behavior in the compiler causes the variadic -// version below to throw a false positive error when passing a single param under very specific -// conditions. This version is a workaround that can be used in those cases. -// -// Reproducible case: -// ```swift -// try #swizzle( -// SUT.functionWithParamsWithReturn, -// params: Int.self, -// returning: Int.self -// ) { $self, state in -// self.functionWithParamsWithReturn(state) // 🛑 error: Cannot pass value pack expansion to non-pack parameter of type 'Int' -// } +@available(*, deprecated, renamed: "swizzle(_:params:returning:implementation:)") @discardableResult @freestanding(expression) public macro swizzle( diff --git a/Tests/SwizzlingTests/SwizzleTests.swift b/Tests/SwizzlingTests/SwizzleTests.swift index f83d391..ae7b3bd 100644 --- a/Tests/SwizzlingTests/SwizzleTests.swift +++ b/Tests/SwizzlingTests/SwizzleTests.swift @@ -111,7 +111,7 @@ extension SwizzleTests { func `swizzle function with parameters and without a return value`() throws { let hook = try #swizzle( SUT.functionWithParamsWithoutReturn, - param: Int.self, + params: Int.self, ) { $self, state in self.functionWithParamsWithoutReturn(state + 1) } @@ -130,7 +130,7 @@ extension SwizzleTests { func `swizzle function with parameters and a return value`() throws { let hook = try #swizzle( SUT.functionWithParamsWithReturn, - param: Int.self, + params: Int.self, returning: Int.self, ) { $sut, value in sut.functionWithParamsWithReturn(value + 1)