Visitar URL original
LTS BACKPORT 12.2.x - fix(compiler): ensure that partially compiled queries can handle forward references by petebacondarwin · Pull Request #44124 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20220131204504/https://github.com/angular/angular/pull/44124
Skip to content
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

LTS BACKPORT 12.2.x - fix(compiler): ensure that partially compiled queries can handle forward references #44124

Conversation

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Nov 9, 2021

LTS backport to 12.2.x of #44113

This interface will be used in other situations so this change renames it to be more general as `MaybeForwardRefExpression`.
@google-cla google-cla bot added the cla: yes label Nov 9, 2021
…ard references

When a partially compiled component or directive is "linked" in JIT mode, the body
of its declaration is evaluated by the JavaScript runtime. If a class is referenced
in a query (e.g. `ViewQuery` or `ContentQuery`) but its definition is later in the
file, then the reference must be wrapped in a `forwardRef()` call.

Previously, query predicates were not wrapped correctly in partial declarations
causing the code to crash at runtime. In AOT mode, this code is never evaluated
but instead transformed as part of the build, so this bug did not become apparent
until Angular Material started running JIT mode tests on its distributable output.

This change fixes this problem by noting when queries are wrapped in `forwardRef()`
calls and ensuring that this gets passed through to partial compilation declarations
and then suitably stripped during linking.

See angular/components#23882 and angular/components#23907
@ngbot
Copy link

@ngbot ngbot bot commented Nov 12, 2021

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "ci/circleci: components-repo-unit-tests" is failing
    failure status "ci/circleci: legacy-unit-tests-saucelabs" is failing
    failure status "ci/circleci: test_win" is failing
    pending status "google3" is pending
    pending status "pullapprove" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Nov 12, 2021

Caretaker: this is a backport. I "think" the failing CI tests are not related to this change.

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Nov 15, 2021

@petebacondarwin this PR is in the "draft" mode. Could you please confirm if it's ok to change it and proceed with the merge?

@petebacondarwin petebacondarwin marked this pull request as ready for review Nov 15, 2021
@petebacondarwin
Copy link
Member Author

@petebacondarwin petebacondarwin commented Nov 15, 2021

@petebacondarwin this PR is in the "draft" mode. Could you please confirm if it's ok to change it and proceed with the merge?

@AndrewKushnir - oops sorry. I forgot to mark it ready.

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Nov 16, 2021

This PR was merged into the repository by commit e3db038.

AndrewKushnir added a commit that referenced this issue Nov 16, 2021
#44124)

This interface will be used in other situations so this change renames it to be more general as `MaybeForwardRefExpression`.

PR Close #44124
AndrewKushnir added a commit that referenced this issue Nov 16, 2021
…ard references (#44124)

When a partially compiled component or directive is "linked" in JIT mode, the body
of its declaration is evaluated by the JavaScript runtime. If a class is referenced
in a query (e.g. `ViewQuery` or `ContentQuery`) but its definition is later in the
file, then the reference must be wrapped in a `forwardRef()` call.

Previously, query predicates were not wrapped correctly in partial declarations
causing the code to crash at runtime. In AOT mode, this code is never evaluated
but instead transformed as part of the build, so this bug did not become apparent
until Angular Material started running JIT mode tests on its distributable output.

This change fixes this problem by noting when queries are wrapped in `forwardRef()`
calls and ensuring that this gets passed through to partial compilation declarations
and then suitably stripped during linking.

See angular/components#23882 and angular/components#23907

PR Close #44124
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Dec 17, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants