-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[NFC] Correct assumptions about static AbstractStorageDecls #23724
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
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
* Moves the IsStatic flag from VarDecl to AbstractStorageDecl. * Adds a StaticSubscriptKind to SubscriptDecl. * Updates serialization for these changes. * Updates SubscriptDecl constructor call sites for these changes.
Rather than figuring out which kind of decl we’re using and then testing the traits it has, check each trait once on the decls where the AST can express it. This change is NFC currently, but will support static subscripts.
Fixes various places where we assume that only a VarDecl can be static so they operate on any AbstractStorageDecl instead. NFC until static subscripts are added.
We currently assume that, if a subscript is declared within a value type’s decl, it must need `self` to be passed inout. This isn’t true for static subscripts, because even though the DeclContext is a value type, the metatype is actually a reference type. Skip this check for non-instance members. NFC until static subscripts are added.
@swift-ci please smoke test |
slavapestov
approved these changes
Apr 2, 2019
xedin
approved these changes
Apr 2, 2019
@swift-ci please test source compatibility |
@swift-ci please smoke test compiler performance |
This was referenced Apr 3, 2019
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.
This PR contains some of the refactoring needed to support static subscripts:
AbstractStorageDecl
and its subclasses to allow the AST to express the idea of a static subscript.AbstractStorageDecl
toVarDecl
before checking staticness. These changes are mostly mechanical, but I've nontrivially refactored one place in override checking.self
parameter of a subscript is never a metatype.It does not modify the parser to accept
static
modifiers on subscripts, nor does it modify the type checker to allow subscripts to be applied to metatypes, so there should not be a way to create or use a static subscript. It also tries not to add much new code which will only be exercised when handling a static subscript.I'd like to land these changes early to give them a little more time to bake and to avoid repeated merge conflicts, particularly on the serialization version number. This PR by itself should not cause any behavior changes; #23358, which implements static subscripts, includes tests verifying that the relevant features behave correctly with static subscripts.
This is a draft PR for the moment because I don't want to land it until we have a toolchain of #23358.