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

Support protocol init requirements #81

Open
bradleymackey opened this issue Jan 20, 2024 · 1 comment
Open

Support protocol init requirements #81

bradleymackey opened this issue Jan 20, 2024 · 1 comment

Comments

@bradleymackey
Copy link

Is your feature request related to a problem? Please describe.
A spy is currently unable to be generated for init requirements. Any protocol with an init requirement will not synthesize correctly.

Describe the solution you'd like

protocol Thing {
  init(time: Double)
}

Should generate:

class ThingSpy: Thing {
  init() {}
  var initTimeReceivedTime: Double!
  required init(time: Double) {
    initTimeReceivedTime = time
  }
}

Describe alternatives you've considered
N/A

Additional context

  • A default init without any parameters should still be generated.
  • Only 1 value needs to be captured from the init requirements, because the object can only be created once.
  • init protocol requirements must be prefixed with the required keyword.
@Boowman
Copy link

Boowman commented Feb 6, 2024

I 2nd this, had the same issue when I started using it.

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

No branches or pull requests

2 participants