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

fix(ivy): throw a better error when DI can't inject a ctor param #33739

Closed
wants to merge 1 commit into from

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented Nov 11, 2019

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new invalidFactoryDep
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

@alxhub alxhub force-pushed the di/missing-decorator-runtime branch 4 times, most recently from 3c6c287 to 6196365 Compare November 11, 2019 22:46
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! Some nits

packages/core/test/render3/ivy/jit_spec.ts Outdated Show resolved Hide resolved
.toThrowError(
/constructor is not compatible with Angular Dependency Injection because its dependency for its parameter 2 is invalid/);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test for the missing directive decorator case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@kara kara marked this pull request as ready for review November 11, 2019 23:47
@kara kara requested review from a team as code owners November 11, 2019 23:47
@kara kara added area: compiler Issues related to `ngc`, Angular's template compiler comp: ivy labels Nov 12, 2019
@ngbot ngbot bot modified the milestone: needsTriage Nov 12, 2019
@alxhub alxhub force-pushed the di/missing-decorator-runtime branch from 6196365 to d7f2cda Compare November 15, 2019 23:54
@alxhub alxhub force-pushed the di/missing-decorator-runtime branch from d7f2cda to 2f8a0ec Compare November 19, 2019 22:07
@alxhub alxhub added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Nov 19, 2019
@alxhub alxhub requested a review from kara November 20, 2019 00:15
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@kara kara added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Nov 20, 2019
@kara
Copy link
Contributor

kara commented Nov 20, 2019

merge-assistance: global approval

@kara kara added the action: presubmit The PR is in need of a google3 presubmit label Nov 20, 2019
@alxhub
Copy link
Member Author

alxhub commented Nov 20, 2019

Presubmit
Ivy Presubmit

@mhevery
Copy link
Contributor

mhevery commented Nov 27, 2019

Needs rebase and fails g3

packages/core/src/di/injector_compatibility.closure.js:145: ERROR - [JSC_UNDEFINED_VARIABLE] variable ngDevMode is undeclared
    const msg = ngDevMode ?
                ^^^^^^^^^

1 error(s), 0 warning(s)

@AndrewKushnir AndrewKushnir added state: blocked and removed 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 labels Dec 5, 2019
@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Dec 5, 2019
Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637
@alxhub alxhub force-pushed the di/missing-decorator-runtime branch from 2f8a0ec to e09bc43 Compare December 7, 2019 00:00
@alxhub
Copy link
Member Author

alxhub commented Dec 7, 2019

Presubmit
Ivy Presubmit

@alxhub alxhub added action: merge The PR is ready for merge by the caretaker and removed state: blocked labels Dec 7, 2019
AndrewKushnir pushed a commit to AndrewKushnir/angular that referenced this pull request Dec 11, 2019
…ular#33739)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637

PR Close angular#33739
AndrewKushnir pushed a commit that referenced this pull request Dec 11, 2019
) (#34340)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes #33637

PR Close #33739

PR Close #34340
josephperrott pushed a commit to josephperrott/angular that referenced this pull request Dec 11, 2019
…ular#33739)

Occasionally a factory function needs to be generated for an "invalid"
constructor (one with parameters types which aren't injectable). Typically
this happens in JIT mode where understanding of parameters cannot be done in
the same "up-front" way that the AOT compiler can.

This commit changes the JIT compiler to generate a new `invalidFactoryDep`
call for each invalid parameter. This instruction will error at runtime if
called, indicating both the index of the invalid parameter as well as (via
the stack trace) the factory function which was generated for the type being
constructed.

Fixes angular#33637

PR Close angular#33739
@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 Jan 9, 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: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants