New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SE-0400: State limitations #2389
base: main
Are you sure you want to change the base?
Conversation
@hborla ping |
proposals/0400-init-accessors.md
Outdated
## Source compatibility | ||
|
||
`init` accessors are an additive capability with new syntax; there is no impact on existing source code. | ||
|
||
## ABI compatibility | ||
|
||
`init` accessors are only called from within a module, so they are not part of the module's ABI. In cases where a type's initializer is `@inlinable`, the body of an `init` accessor must also be inlinable. | ||
`init` accessors are only called from within a source file, so they are not part of the module's ABI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original text is correct. Even if you can only define init accessors in the primary declaration of a type, you can add an initializer in another source file that will call the init accessor:
// in FirstFile.swift
struct S {
var _x: Int
var x: Int {
@storageRestrictions(initializes: _x)
init {
self._x = newValue
}
get { _x }
}
}
// in SecondFile.swift
extension S {
init() {
self.x = 10
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We had a crash report with like the simplest example of an init accessor use across files, and I was not sure if this sentence really meant they could be internal
because the forum topics appeared to settle on fileprivate
. I could have just inferred it from the inlinable
business that follows, really. But I still think this paragraph would benefit from a little more straightforwardness and accuracy (see the latest revision).
cc @hborla
See apple/swift#71578.