Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(compiler): process imports first and declarations second while calculating scopes #35850

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

Closed

Conversation

AndrewKushnir
Copy link
Contributor

Prior to this commit, while calculating the scope for a module, Ivy compiler processed declarations field first and imports after that. That results in a couple issues:

  • for Pipes with the same name and present in declarations and in an imported module, Pipe from imported module was selected. In View Engine the logic is opposite: Pipes from declarations field receive higher priority.
  • for Directives with the same selector and present in declarations and in an imported module, we first invoked the logic of a Directive from declarations field and after that - imported Directive logic. In View Engine, it was the opposite and the logic of a Directive from the declarations field was invoked last.

In order to align Ivy and View Engine behavior, this commit updates the logic in which we populate module scope: we first process all imports and after that handle declarations field. As a result, in Ivy both use-cases listed above work similar to View Engine.

Resolves #35502.

PR Type

What kind of change does this PR introduce?

  • Bugfix

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added type: bug/fix state: WIP target: patch This PR is targeted for the next patch release comp: ivy area: compiler Issues related to `ngc`, Angular's template compiler labels Mar 4, 2020
@ngbot ngbot bot added this to the needsTriage milestone Mar 4, 2020
@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Mar 4, 2020
@AndrewKushnir AndrewKushnir marked this pull request as ready for review March 4, 2020 17:51
@pullapprove pullapprove bot requested a review from kara March 4, 2020 17:51
@AndrewKushnir AndrewKushnir requested review from alxhub and kara and removed request for kara March 4, 2020 17:51
Copy link
Member

@alxhub alxhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. I really don't like relying on the orderedness of Set, but this will work for now.

…e calculating scopes

Prior to this commit, while calculating the scope for a module, Ivy compiler processed `declarations` field first and `imports` after that. That results in a couple issues:

* for Pipes with the same `name` and present in `declarations` and in an imported module, Pipe from imported module was selected. In View Engine the logic is opposite: Pipes from `declarations` field receive higher priority.
* for Directives with the same selector and present in `declarations` and in an imported module, we first invoked the logic of a Directive from `declarations` field and after that - imported Directive logic. In View Engine, it was the opposite and the logic of a Directive from the `declarations` field was invoked last.

In order to align Ivy and View Engine behavior, this commit updates the logic in which we populate module scope: we first process all imports and after that handle `declarations` field. As a result, in Ivy both use-cases listed above work similar to View Engine.

Resolves angular#35502.
@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Mar 8, 2020
@AndrewKushnir AndrewKushnir force-pushed the FW-1874_scope_calc_order branch from ccd466f to fc6fe12 Compare March 8, 2020 21:57
@AndrewKushnir
Copy link
Contributor Author

@AndrewKushnir
Copy link
Contributor Author

FYI, both Blueprint and Global TAP runs (with Ivy) with the changes from this PR are successful.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Mar 9, 2020
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pkozlowski-opensource pkozlowski-opensource added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 10, 2020
@pkozlowski-opensource pkozlowski-opensource removed the request for review from kara March 10, 2020 13:18
matsko pushed a commit that referenced this pull request Mar 10, 2020
…e calculating scopes (#35850)

Prior to this commit, while calculating the scope for a module, Ivy compiler processed `declarations` field first and `imports` after that. That results in a couple issues:

* for Pipes with the same `name` and present in `declarations` and in an imported module, Pipe from imported module was selected. In View Engine the logic is opposite: Pipes from `declarations` field receive higher priority.
* for Directives with the same selector and present in `declarations` and in an imported module, we first invoked the logic of a Directive from `declarations` field and after that - imported Directive logic. In View Engine, it was the opposite and the logic of a Directive from the `declarations` field was invoked last.

In order to align Ivy and View Engine behavior, this commit updates the logic in which we populate module scope: we first process all imports and after that handle `declarations` field. As a result, in Ivy both use-cases listed above work similar to View Engine.

Resolves #35502.

PR Close #35850
@matsko matsko closed this in 0bf6e58 Mar 10, 2020
@angular-automatic-lock-bot
Copy link

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 Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler cla: yes target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User defined pipes vs builtin pipes
4 participants