Implicitly initialize fields in typed converter #28151
Draft
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 utilizes information from the frontend resolver to generate converted AST for implicitly initialized fields. Implicitly initialized fields in branches will be addressed in future PRs. This effort required some modifications to the frontend:
Split 'resolveFieldDecl` to store results separately
This PR splits out some of the logic in
resolveFieldDeclso that we can re-query and fetch the RRBPID later. This new query is calledresolveFieldResults, and returns a type introduced by this commit calledResolvedFieldResults. This new type primarily stores the RRBPID computed by a Resolver, but also stores some useful information alongside the resolution results.A convenience query, called
resolvedFieldsFromResults, that can be combined withresolveFieldResultsto achieve the same output asresolveFieldDecl.This PR also fixes a minor bug when initializing the
ResolvedFieldsstructure. Previously the given RRBPID was not const, so invoking 'byAst' would create an empty entry. Instead, we check if we're insyntaxOnlymode, in which case there will not be results and we should instead create an unknown QualifiedType.Store implicit initialization information in ResolvedFunction
This PR adds key data about implicitly initialized fields within an initializer, to be used later during typed conversion. Initially this information is a basic map of IDs before which the fields should be initialized, but will likely need to evolve to handle more complex cases related to e.g., branching. Currently, an empty ID indicates that the fields need to be initialized at the end of the initializer.
InitResolver is udpated to collect this information, which is then requested upon creation of the ResolvedFunction.
Testing: