Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): infinite loop if injectable using inheritance has a custom…
… decorator (#37022) If we detect that an injectable class is inheriting from another injectable, we generate code that looks something like this: ``` const baseFactory = ɵɵgetInheritedFactory(Child); @Injectable() class Parent {} @Injectable() class Child extends Parent { static ɵfac = (t) => baseFactory(t || Child) } ``` This usually works fine, because the `ɵɵgetInheritedFactory` resolves to the factory of `Parent`, but the logic can break down if the `Child` class has a custom decorator. Custom decorators can return a new class that extends the original once, which means that the `ɵɵgetInheritedFactory` call will now resolve to the factory of the `Child`, causing an infinite loop. These changes fix the issue by changing the inherited factory resolution logic so that it walks up the prototype chain class-by-class, while skipping classes that have the same factory as the class that was passed in. Fixes #35733. PR Close #37022
- Loading branch information
Showing
2 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters