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
Contributor

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.

@googlebot googlebot added the cla: yes label Nov 11, 2019
@alxhub alxhub force-pushed the alxhub:di/missing-decorator-runtime branch 4 times, most recently from 3c6c287 to 6196365 Nov 11, 2019
Copy link
Contributor

kara left a comment

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/);
});
});

This comment has been minimized.

Copy link
@kara

kara Nov 11, 2019

Contributor

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

This comment has been minimized.

Copy link
@alxhub

alxhub Dec 7, 2019

Author Contributor

Done!

@kara kara marked this pull request as ready for review Nov 11, 2019
@kara kara requested review from angular/fw-compiler as code owners Nov 11, 2019
@ngbot ngbot bot modified the milestone: needsTriage Nov 12, 2019
@alxhub alxhub force-pushed the alxhub:di/missing-decorator-runtime branch from 6196365 to d7f2cda Nov 15, 2019
@alxhub alxhub force-pushed the alxhub:di/missing-decorator-runtime branch from d7f2cda to 2f8a0ec Nov 19, 2019
@alxhub alxhub requested a review from kara Nov 20, 2019
@kara
kara approved these changes Nov 20, 2019
Copy link
Contributor

kara left a comment

LGTM

@kara

This comment has been minimized.

Copy link
Contributor

kara commented Nov 20, 2019

merge-assistance: global approval

@alxhub

This comment has been minimized.

Copy link
Contributor Author

alxhub commented Nov 20, 2019

@mhevery

This comment has been minimized.

Copy link
Member

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)
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
@alxhub alxhub force-pushed the alxhub:di/missing-decorator-runtime branch from 2f8a0ec to e09bc43 Dec 7, 2019
@alxhub

This comment has been minimized.

Copy link
Contributor Author

alxhub commented Dec 7, 2019

AndrewKushnir added 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 added 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 added 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

This comment has been minimized.

Copy link

angular-automatic-lock-bot bot commented Jan 9, 2020

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.
Projects
None yet
6 participants
You can’t perform that action at this time.