initializer is inaccessible due to 'private' protection level
error when not all struct properties are private
#64738
Labels
access control
Feature → modifiers: Access control and access levels
compiler
The Swift compiler in itself
feature
A feature request or implementation
memberwise init
Feature: Memberwise structure initializers
swift evolution proposal needed
Flag → feature: A feature that warrants a Swift evolution proposal
Description
Consider the following code:
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:However, this is not always a desired behavior.
Solution
Generate an additional,
internal
memberwise initializer forx
, or more fine control over which properties contribute to the generated init.The text was updated successfully, but these errors were encountered: