-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Correctly detect deferred dependencies inside scoped node and reorganize defer tests #54499
Conversation
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.
@crisbeto thanks for the fix 👍
…ed nodes This is based on an internal issue report. An earlier change introduced a diagnostic to report cases where a symbol is in the `deferredImports` array, but is used eagerly. The check worked by looking through the deferred blocks in a scope, resolving the scope for each and checking if the element is within the scope. The problem is that resolving the scope won't work across scoped node boundaries. For example, if there's a control flow statement around the block or within the block but around the deferred dependency, it won't be able to resolve the scope since it isn't a direct child, e.g. ``` @if (true) { @defer { <deferred-dep/> } } ``` To fix this the case where the deferred block is inside a scoped node, I've changed the `R3BoundTarget.deferBlocks` to be a `Map` holding both the deferred block and its corresponding scope. Then to resolve the case where the dependency is within a scoped node inside the deferred block, I've added a depth-first traversal through the scopes within the deferred block.
Splits the tests for `@defer` blocks out into a separate file since the `ngtsc_spec.ts` is getting quite large.
649efd5
to
7bccc28
Compare
This PR was merged into the repository by commit a9f563f. |
…ed nodes (#54499) This is based on an internal issue report. An earlier change introduced a diagnostic to report cases where a symbol is in the `deferredImports` array, but is used eagerly. The check worked by looking through the deferred blocks in a scope, resolving the scope for each and checking if the element is within the scope. The problem is that resolving the scope won't work across scoped node boundaries. For example, if there's a control flow statement around the block or within the block but around the deferred dependency, it won't be able to resolve the scope since it isn't a direct child, e.g. ``` @if (true) { @defer { <deferred-dep/> } } ``` To fix this the case where the deferred block is inside a scoped node, I've changed the `R3BoundTarget.deferBlocks` to be a `Map` holding both the deferred block and its corresponding scope. Then to resolve the case where the dependency is within a scoped node inside the deferred block, I've added a depth-first traversal through the scopes within the deferred block. PR Close #54499
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Note for reviewer: it may be easier to look through this commit-by-commit since I took the chance to reorganize our tests a bit so they're easier to navigate. Includes the following changes:
fix(compiler-cli): correctly detect deferred dependencies across scoped nodes
This is based on an internal issue report.
An earlier change introduced a diagnostic to report cases where a symbol is in the
deferredImports
array, but is used eagerly. The check worked by looking through the deferred blocks in a scope, resolving the scope for each and checking if the element is within the scope. The problem is that resolving the scope won't work across scoped node boundaries. For example, if there's a control flow statement around the block or within the block but around the deferred dependency, it won't be able to resolve the scope since it isn't a direct child, e.g.To fix this the case where the deferred block is inside a scoped node, I've changed the
R3BoundTarget.deferBlocks
to be aMap
holding both the deferred block and its corresponding scope. Then to resolve the case where the dependency is within a scoped node inside the deferred block, I've added a depth-first traversal through the scopes within the deferred block.refactor(compiler-cli): move defer block tests into separate file
Splits the tests for
@defer
blocks out into a separate file since thengtsc_spec.ts
is getting quite large.