-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Generalize accessor storage to preserve the original accessor list. #17238
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
Conversation
@swift-ci Please test. |
Build failed |
Build failed |
|
||
/// Either 0, meaning there is no registered accessor of the given kind, | ||
/// or the index+1 of the accessor in the accessors array. | ||
AccessorIndex AccessorIndices[NumAccessorKinds]; |
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.
Can you use llvm::TrailingObjects instead of a supposed fixed-sized array?
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.
That is a fixed-size array; it's indexed by AccessorKinds. There is a trailing-objects use in that type, though.
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.
Oops, my brain misread NumAccessorKinds as MaxNumAccessors. Sorry for the noise!
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've updated to use TrailingObjects for the part that's actually a trailing array.
3f1e547
to
841e69b
Compare
@swift-ci Please test. |
Build failed |
Build failed |
841e69b
to
3c44d64
Compare
@swift-ci Please test. |
Build failed |
Build failed |
3c44d64
to
33014de
Compare
@swift-ci Please test. |
Build failed |
Build failed |
33014de
to
fc64f54
Compare
@swift-ci Please test. |
Build failed |
Build failed |
fc64f54
to
7f259cc
Compare
@swift-ci Please test. |
Build failed |
Build failed |
@@ -4367,13 +4367,14 @@ public class FooOverlayClassDerived : Foo.FooOverlayClassBase { | |||
{ | |||
key.kind: source.lang.swift.decl.var.global, | |||
key.accessibility: source.lang.swift.accessibility.public, | |||
key.setter_accessibility: source.lang.swift.accessibility.public, |
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.
@benlangmuir @nkcsgexi I'm pretty sure that these changes are good — these are the global aliases we emit for C enumerators, so (1) they're not settable and (2) they do have the body {get}
IIUC — but they're not intentional, so I'd feel better with a thumbs up. :)
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 understand why these changes occurred now. The generated interface file contains snippets like var x: Int {get}
in all sorts of contexts. If you ask Swift to parse this, it will usually reject it because the accessor does not have a body. Previously, the parser wouldn't even make an AccessorDecl for the accessor, with two effects: first, there's no AST node for the syntax library to associate with the syntax, leading it to state that the variable has no body; and second, the parser sees a variable with no accessors and mistakenly decides it must be stored, and all stored variables are settable. My patch preserves the incomplete accessor declaration and properly considers the variable to be computed, leading to these changes. This is a clear improvement in our output.
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.
LGTM
7f259cc
to
de4d56b
Compare
Test failure is a consequence of other changes. Rebasing and resubmitting. |
@swift-ci Please test. |
Build failed |
Build failed |
36ad0c3
to
5506a1a
Compare
@swift-ci Please test. |
Build failed |
Build failed |
Only not NFC because it's detectable by source tools.
5506a1a
to
69f4dd1
Compare
@swift-ci Please test. |
Build failed |
Build failed |
Only not NFC because it's detectable by source tools.