Interestingly, I found that it's significant for memberwise initializers of private nominal types to have internal (not private) access.
func foo() {
struct Private {}
// Call the internal memberwise initializer: okay.
_ = Private()
}
func foo() {
struct Private {
private init() {}
}
// Call the private memberwise initializer: not okay.
_ = Private()
}
// private.swift:6:7: error: 'Private' initializer is inaccessible due to 'private' protection level
// _ = Private()
// ^
// private.swift:3:13: note: 'init()' declared here
// private init() {}
// ^
For context, I discovered this in [AutoDiff] Change `TangentVector` memberwise initializer access level. by dan-zheng · Pull Request #28908 · apple/swift · GitHub, the motivation for this question: memberwise initializer access level for TangentVector
member structs synthesized during Differentiable
protocol derived conformances.