You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of Swift are you using (swift --version)?
swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1)
Target: arm64-apple-macosx14.0
What did you do?
I'm using Sourcery 2.2.5 and the default Automockable.stencil template. The default template for Automockable, parses and generates not compiler safe code.
Given the following code:
When building and trying to generate mocked code, the compiler will fail and tell that the newly generated code has wrong syntax.
This is the generated code it came up with:
This does not work because of the followintg compiler errors:
What is the actual problem?
The problem is, that it replaces every ? with )? which should not be the case for the Any? parameter.
This happens only, and only if:
The parameter is a closure
Is optional
contains:"any "
The replace function is too naive and adds too many parentheses.
Here are the lines, which are in my opinion, the places where the replace is to generous:
Here is a naive solution I have in mind. Please check it out and let me know if thats the correct way to go forward or not.
I'd also like to contribute and help solving this issue if possible.
@lucaArchidiacono if you submit PR will be able to see if there are any tests failing with that approach, we can deal with that and get it merged into upstream then, would appreciate it!
What version of Swift are you using (swift --version)?
What did you do?
I'm using Sourcery
2.2.5
and the defaultAutomockable.stencil
template. The default template forAutomockable
, parses and generates not compiler safe code.Given the following code:
What did you expect to see?
I expect the default
Automockable.stencil
to generate compiler safe code. I expected that it generates the following code:What did you see instead?
When building and trying to generate mocked code, the compiler will fail and tell that the newly generated code has wrong syntax.
This is the generated code it came up with:
This does not work because of the followintg compiler errors:
What is the actual problem?
The problem is, that it replaces every
?
with)?
which should not be the case for theAny?
parameter.This happens only, and only if:
closure
optional
contains:"any "
The replace function is too naive and adds too many parentheses.
Here are the lines, which are in my opinion, the places where the replace is to generous:
Sourcery/Templates/Templates/AutoMockable.stencil
Line 254 in 3da93a7
Sourcery/Templates/Templates/AutoMockable.stencil
Line 310 in 3da93a7
The text was updated successfully, but these errors were encountered: