-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Another pile of availability checking fixes #34390
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
Merged
slavapestov
merged 10 commits into
swiftlang:main
from
slavapestov:misc-availability-fixes
Oct 22, 2020
Merged
Another pile of availability checking fixes #34390
slavapestov
merged 10 commits into
swiftlang:main
from
slavapestov:misc-availability-fixes
Oct 22, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…leFunctionKind() getFragileFunctionKind() would report that all initializers in non-resilient public types were inlinable, including static properties. This was later patched by VarDecl::isInitExposedToClients(), which was checked in diagnoseInlinableDeclRefAccess(). However, the latter function only looked at the innermost DeclContexts, not all parent contexts, so it would incorrectly diagnose code with a nested DeclContext inside of a static property initializer. Fix this by changing getFragileFunctionKind() to call isInitExposedToClients() and simplifying diagnoseInlinableDeclRefAccess(). This commit also introduces a new isLayoutExposedToClients() method, which is similar to isInitExposedToClients(), except it also returns 'true' if the property does not have an initializer (and in fact the latter is implemented in terms of the former).
There's no need to check for that here, because we also run diagnoseDeclRefExportability() on declarations referenced from inlinable code. This changes some diagnostics; we now produce the same diagnostic for references to SPI types in declaration signatures and for references to non-type SPI declarations in inlinable function bodies. Also note that the old inlinable reference diagnostic no longer has to handle the 'public' and 'open' access levels, which previously happened for '@_spi'; so I changed those entries in the %select to %error.
…Frozen structs We require that all stored properties in a @Frozen struct have public or @usableFromInline types, even if the property itself is not public. This is so that clients can correctly generate code to manipulate the @Frozen struct. This check was only looking for bona-fide stored properties, and missing out looking at properties that have backing storage, namely 'lazy' properties and property wrappers.
…attribute is allowed We need to prohibit 'lazy' properties and property wrappers from being declared @_spi inside of a @Frozen struct. Making them SPI doesn't make sense, because these properties will be omitted from the module interface and not taken into account when clients manipulate values of this type.
@swift-ci Please test source compatibility |
@swift-ci Please test |
Build failed |
Even if a nominal type does not have its own generic parameters, we need to visit its conformances, because it might be defined in a constrained extension or have a 'where' clause of its own.
Build failed |
In @Frozen structs, stored properties and property wrappers must have inlinable initial value expressions, since they are re-emitted into designated initializer bodies, which themselves might be @inlinable. However, 'lazy' properties don't follow this pattern; the initial value expression is emitted inside the getter, which is never @inlinable.
3b16db7
to
8af4405
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See the individual commits for details.