Open
Description
Description
Consider the following code:
struct Struct {
var x: Int
private var y: Int = 0
}
do {
let _ = Struct(x: 0)
}
Despite x
not being private, the "inaccessible initializer" error is emitted.
One fix is to change y
to a constant so that it doesn’t contribute to the generated initializer:
struct Struct {
var x: Int
private let y: Int = 0
}
However, this is not always a desired behavior.
Solution
Generate an additional, internal
memberwise initializer for x
, or more fine control over which properties contribute to the generated init.