Dyno: Improve initializers on classes that inherit #25965
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.