-
Notifications
You must be signed in to change notification settings - Fork 421
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
Dyno: Improve initializers on classes that inherit #25965
Merged
Merged
Conversation
This file contains 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
benharsh
changed the title
Improve initializers on classes that inherit
Dyno: Improve initializers on classes that inherit
Sep 18, 2024
riftEmber
requested changes
Sep 20, 2024
I think I've addressed the items above if you want to take another look. |
riftEmber
approved these changes
Sep 20, 2024
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.
looks good!
This commit improves support for initializers on classes that inherit. With this commit dyno now supports: - implicit 'super.init' calls - errors for accessing parent fields before 'super.init' - usage of initialized fields part-way through initializing the whole type This commit updates the Resolver to rely somewhat less on 'InitResolver' for explicitly handling ``Identifier`` and ``Dot`` uAST nodes. Instead we continue to rely on established Resolver mechanisms and selectively invoke the ``InitResolver`` when appropriate. This commit also improves a fix within 'handleCallExpr' originally meant to support receiver-less 'init' calls. Instead, this fix is adapted to any 'init' call within an initializer, and will replace or create the receiver using a fully-generic type. This is done in case the user has erroneously initialized fields prior to the explicit 'init' call. ------------------ The ``fieldIdFromPossibleMentionOfField`` helper method is updated to return a field ID (if found) and whether that field is a parent field. Some logic from ``handleCallToSuperInit`` is split off into a new ``updateSuperType`` method to better support the implicit 'super.init' case. Minor fixes to ``findFieldByName`` - Use ``VarLikeDecl`` instead, as ``NamedDecl`` can match primary methods. - Do not continue searching upwards if the parent class is the root class. Lastly, this commit adds tests for newly supported initializer behavior Signed-off-by: Ben Harshbarger <[email protected]>
…omPossibleMentionOfField Signed-off-by: Ben Harshbarger <[email protected]>
Signed-off-by: Ben Harshbarger <[email protected]>
…add test case Signed-off-by: Ben Harshbarger <[email protected]>
…sses before an 'init' call Signed-off-by: Ben Harshbarger <[email protected]>
benharsh
force-pushed
the
improve-super-init
branch
from
September 25, 2024 20:09
9e9059d
to
a35504e
Compare
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 improves support for initializers on classes that inherit. With this commit dyno now supports:
This PR updates the Resolver to rely somewhat less on 'InitResolver' for explicitly handling
Identifier
andDot
uAST nodes. Instead we continue to rely on established Resolver mechanisms and selectively invoke theInitResolver
when appropriate.This PR also improves a fix within 'handleCallExpr' originally meant to support receiver-less 'init' calls. Instead, this fix is adapted to any 'init' call within an initializer, and will replace or create the receiver using a fully-generic type. This is done in case the user has erroneously initialized fields prior to the explicit 'init' call. I plan on moving this behavior into
InitResolver
in the future.The
fieldIdFromPossibleMentionOfField
helper method is updated to return a field ID (if found) and whether that field is a parent field.Some logic from
handleCallToSuperInit
is split off into a newupdateSuperType
method to better support the implicit 'super.init' case.Minor fixes to
findFieldByName
VarLikeDecl
instead, asNamedDecl
can match primary methods.Lastly, this commit adds tests for newly supported initializer behavior.