SwiftFormat seems to take init-accessors as actual initializers:
struct MyStruct {
private var __myVar: String
var myVar: String {
@storageRestrictions(initializes: __myVar)
init { /// <---------- NOT AN INITIALIZER
self.__myVar = newValue /// Original code makes some adjustments here
}
set {
self.__myVar = newValue /// Original code makes some adjustments here
}
get {
self.__myVar
}
}
}
This makes some rules like --self init-only affect init-accessors while they shouldn't.
Solution is to make sure SwiftFormat takes these into consideration:
1- If init does not have a () then it's not an actual initializer.
2- If init only has a single untyped parameter in the () then it's not an actual initializer. Example: init(initialValue).
SwiftFormat seems to take init-accessors as actual initializers:
This makes some rules like
--self init-only
affect init-accessors while they shouldn't.Solution is to make sure SwiftFormat takes these into consideration: 1- If
init
does not have a()
then it's not an actual initializer. 2- Ifinit
only has a single untyped parameter in the()
then it's not an actual initializer. Example:init(initialValue)
.Somewhat related issue: https://github.com/nicklockwood/SwiftFormat/issues/1710 Related proposal: https://github.com/apple/swift-evolution/blob/main/proposals/0400-init-accessors.md