Closed Cyberbeni closed 2 years ago
@Cyberbeni this is mentioned in the README:
If you assign
SomeClass.self
to a variable and then instantiate an instance of the class using that variable, Swift requires that you use an explicit.init()
, however, theredundantInit
rule is not currently capable of detecting this situation and will remove the.init
. To work around this issue, use the// swiftformat:disable:next redundantInit
comment directive to disable the rule for any affected lines of code (or just disable theredundantInit
rule completely).
I probably could detect simple cases where the type is declared locally though - I'll see if I can improve this behavior a bit.
Ah, there is also already an issue with the same name 🙈 #299
I'm testing SE-0309 with the 5.7 toolchain and ran into a problem with swiftformat, that is also present for earlier swift versions (only tested with the newest one included in Xcode 13.3.1). init gets removed in the below example resulting in the following compiler error:
Initializing from a metatype value must reference 'init' explicitly