Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@DependencyClient and @autoclosure parameters #155

Closed
2 of 3 tasks
xiii111 opened this issue Dec 4, 2023 · 2 comments · Fixed by #160
Closed
2 of 3 tasks

@DependencyClient and @autoclosure parameters #155

xiii111 opened this issue Dec 4, 2023 · 2 comments · Fixed by #160

Comments

@xiii111
Copy link
Contributor

xiii111 commented Dec 4, 2023

Description

This is similar to #146. The code generated by @DependencyClient is incorrect for @autoclosure parameters and generate invalid swift code. it should explicitly refuse to generate code or if possible generate valid code.

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

@DependencyClient
public struct DemoClinet {
    public var execute: (_ closure: @autoclosure () -> String) -> Void
}

Should generate valid swift code

Actual behavior

The code generated :

public func execute(closure p0: @autoclosure () -> String) -> Void {
    self.execute(p0)  // Error occurs: 'Add () to forward @autoclosure parameter'
}

private var _execute: (_ closure: @autoclosure () -> String) -> Void = { _ in
    XCTestDynamicOverlay.XCTFail("Unimplemented: 'execute'")
}

is not valid code: Add () to forward @autoclosure parameter

Steps to reproduce

No response

Dependencies version information

1.1.2

Destination operating system

No response

Xcode version information

15.0.0

Swift Compiler version information

No response

@xiii111 xiii111 added the bug Something isn't working label Dec 4, 2023
@stephencelis
Copy link
Member

@xiii111 Good catch! Do you have any interest in trying to tackle the problem with a pull request? No worries if not. We'll try to get to it soon otherwise 😄

@xiii111
Copy link
Contributor Author

xiii111 commented Dec 5, 2023

@stephencelis Absolutely, I'll give it a try! However, I'm not familiar with SwiftSyntax, so if I can't finish it by the end of this week, I'll reach out to let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants