Open
Description
Use Case
Support covariant Self
used in methods and members with the @Mocked
annotation.
Since our Mocks are final
and Self
is a key word this should be supportable? We detect the usage of Self
and replace with new class name instead of Self
Feature Proposal
I would like @Mocked
to support covariant Self
out of the box. Currently this isn't allowed.
@Mocked protocol Test {
func newInstance() -> Self
}
The code generated is:
@MockedMembers
final class TestMock: Test {
func newInstance() -> Self // compiler error of "Covariant `Self` or `Self?` can only appear at the top level of property type.
}
Instead I would like this code generated:
@MockedMembers
final class TestMock: Test {
func newInstance() -> TestMock
}
This is actually the code Xcode recommends to get around the issue.
Alternatives Considered
Manually building the Mock class using @MockedMembers
. It works but is undesirable.
Additional Context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct