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
Use Case
Support covariant
Selfused in methods and members with the@Mockedannotation.Since our Mocks are
finalandSelfis a key word this should be supportable? We detect the usage ofSelfand replace with new class name instead ofSelfFeature Proposal
I would like
@Mockedto support covariantSelfout of the box. Currently this isn't allowed.The code generated is:
Instead I would like this code generated:
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