Skip to content

fix(compiler-cli): handle inline type-check blocks in nullish coalescing extended check#45454

Closed
JoostK wants to merge 3 commits intoangular:masterfrom
JoostK:ngtsc/ttc/shim-locations
Closed

fix(compiler-cli): handle inline type-check blocks in nullish coalescing extended check#45454
JoostK wants to merge 3 commits intoangular:masterfrom
JoostK:ngtsc/ttc/shim-locations

Conversation

@JoostK
Copy link
Member

@JoostK JoostK commented Mar 26, 2022

This commit fixes an inconsistency where a type check location for an inline
type check block would be interpreted to occur in a type-checking shim instead.
This resulted in a missing template mapping, causing a crash due to an unsafe
non-null assertion operator.

In the prior commit the TcbLocation has been extended with an isShimFile
field that is now being used to look for the template mapping in the correct
location. Additionally, the non-null assertion operator is refactored such
that a missing template mapping will now ignore the warning instead of crashing
the compiler.

Fixes #45413

@JoostK JoostK added target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler labels Mar 26, 2022
@ngbot ngbot bot modified the milestone: Backlog Mar 26, 2022
@JoostK JoostK marked this pull request as ready for review March 27, 2022 08:11
@JoostK JoostK requested a review from atscott March 27, 2022 08:11
@JoostK JoostK added the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 27, 2022
JoostK added 3 commits March 29, 2022 18:36
Inline type check blocks (TCBs) are emitted into the original source file, but
node positions would still be represented as a `ShimLocation` with a `shimPath`
corresponding with the type-checking shim file. This results in inconsistencies,
as the `positionInShimFile` field of `ShimLocation` would not correspond with
the `shimPath` of that `ShimLocation`.

This commit is a precursor to letting `ShimLocation` also represent the correct
location for inline type check blocks, by renaming the interface to
`TcbLocation`. A followup commit addresses the actual inconsistency.
…h a shim file

Extends `TcbPosition` with a field that indicates whether the `tcbPath` is a
type-checking shim file, or an original source file with an inline type check
block.

This field is used in an upcoming commit that fixes an inconsistency with how
inline type check blocks are incorrectly interpreted as a type-checking shim
file instead.
…ing extended check

This commit fixes an inconsistency where a type check location for an inline
type check block would be interpreted to occur in a type-checking shim instead.
This resulted in a missing template mapping, causing a crash due to an unsafe
non-null assertion operator.

In the prior commit the `TcbLocation` has been extended with an `isShimFile`
field that is now being used to look for the template mapping in the correct
location. Additionally, the non-null assertion operator is refactored such
that a missing template mapping will now ignore the warning instead of crashing
the compiler.

Fixes angular#45413
@JoostK JoostK force-pushed the ngtsc/ttc/shim-locations branch from 73341d8 to 14b32fe Compare March 29, 2022 16:36
@atscott
Copy link
Contributor

atscott commented Mar 29, 2022

presubmit

@JoostK JoostK added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 29, 2022
@ngbot
Copy link

ngbot bot commented Mar 29, 2022

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google3" is failing

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.

@JoostK
Copy link
Member Author

JoostK commented Mar 29, 2022

Merge assistance: please check the presubmit failure for me and merge if it's a flake.

@dylhunn
Copy link
Contributor

dylhunn commented Mar 29, 2022

Indeed, this is a flake.

@dylhunn dylhunn added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Mar 29, 2022
@dylhunn
Copy link
Contributor

dylhunn commented Mar 29, 2022

This PR was merged into the repository by commit 06050ac.

@dylhunn dylhunn closed this in b2758d7 Mar 29, 2022
dylhunn pushed a commit that referenced this pull request Mar 29, 2022
…h a shim file (#45454)

Extends `TcbPosition` with a field that indicates whether the `tcbPath` is a
type-checking shim file, or an original source file with an inline type check
block.

This field is used in an upcoming commit that fixes an inconsistency with how
inline type check blocks are incorrectly interpreted as a type-checking shim
file instead.

PR Close #45454
dylhunn pushed a commit that referenced this pull request Mar 29, 2022
…ing extended check (#45454)

This commit fixes an inconsistency where a type check location for an inline
type check block would be interpreted to occur in a type-checking shim instead.
This resulted in a missing template mapping, causing a crash due to an unsafe
non-null assertion operator.

In the prior commit the `TcbLocation` has been extended with an `isShimFile`
field that is now being used to look for the template mapping in the correct
location. Additionally, the non-null assertion operator is refactored such
that a missing template mapping will now ignore the warning instead of crashing
the compiler.

Fixes #45413

PR Close #45454
@dylhunn
Copy link
Contributor

dylhunn commented Mar 29, 2022

This PR has conflicts with 13.3.x, but I've merged it into master. It would need a patch port if the patch branch is desired.

josmar-crwdstffng pushed a commit to josmar-crwdstffng/angular that referenced this pull request Apr 8, 2022
…ar#45454)

Inline type check blocks (TCBs) are emitted into the original source file, but
node positions would still be represented as a `ShimLocation` with a `shimPath`
corresponding with the type-checking shim file. This results in inconsistencies,
as the `positionInShimFile` field of `ShimLocation` would not correspond with
the `shimPath` of that `ShimLocation`.

This commit is a precursor to letting `ShimLocation` also represent the correct
location for inline type check blocks, by renaming the interface to
`TcbLocation`. A followup commit addresses the actual inconsistency.

PR Close angular#45454
@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 29, 2022
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 merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile error related to nullish coalescing in template

3 participants