You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swift-ci opened this issue
Aug 18, 2017
· 3 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselffeatureA feature request or implementation
I think there's an argument to be made for making the memberwise init public if all of the members are public, but not if only the struct is. Doing the latter would make it very easy to accidentally expose an unintentional init to downstream users, and one that changes when members are changed (i.e. one could only modify private code, and still stop downstream code from compiling).
Something that might handle both cases is being able to opt in to the compiler filling in the initializer body if the signature is right, e.g. C++-style public init(x: Int, y: Int) = default or something. This means that any (incompatible) changes to the struct's members will stop the defaulted initializer from compiling, alerting the programmer that they may be breaking downstream code.
Right. This isn't just a bug; it was a deliberate design decision, based on the principle that exposing API across a library boundary should always be explicit.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselffeatureA feature request or implementation
Additional Detail from JIRA
md5: ddb1f014e36d7ba2b77e693c26f30092
relates to:
Issue Description:
If the struct is public, the memberwise init should be automatically created and set public
The text was updated successfully, but these errors were encountered: