fix: compile @Injectable with coexisting PRIMARY decorators on the same class#75
Merged
Brooooooklyn merged 1 commit intomainfrom Mar 5, 2026
Conversation
…me class Angular's `HandlerPrecedence` system allows `@Injectable` (SHARED) to coexist with exactly one PRIMARY decorator (@component, @directive, @pipe, @NgModule). The `else if` chain only processed one decorator per class, so @Injectable would block @Pipe/@NgModule (or vice versa) when both were present. Fix: - Reorder chain: all PRIMARY decorators checked before SHARED @Injectable - Add nested @Injectable checks inside each PRIMARY branch to generate ɵprov - Mirror the same logic in the re-parse decorator span collection section - Fix #65 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Angular's
HandlerPrecedencesystem allows@Injectable(SHARED) to coexistwith exactly one PRIMARY decorator (@component, @directive, @pipe, @NgModule).
The
else ifchain only processed one decorator per class, so @Injectable wouldblock @Pipe/@NgModule (or vice versa) when both were present.
Fix:
Reorder chain: all PRIMARY decorators checked before SHARED @Injectable
Add nested @Injectable checks inside each PRIMARY branch to generate ɵprov
Mirror the same logic in the re-parse decorator span collection section
Fix @Pipe + @Injectable on the same class: @Pipe decorator not compiled, causes JIT fallback #65
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Medium Risk
Touches the core class-decorator compilation/rewriting path, so incorrect branching or span collection could change emitted output for multiple Angular artifact types. Changes are targeted and backed by new regression tests for the coexisting-decorator cases.
Overview
Fixes Angular
HandlerPrecedencebehavior so a class with a PRIMARY decorator (@Component,@Directive,@Pipe,@NgModule) and a SHARED@Injectablenow emits both the primary definition (ɵcmp/ɵdir/ɵpipe/ɵmod/ɵinj) and an injectablestatic ɵprov, instead of only compiling whichever decorator matched the previouselse ifchain.Updates decorator-removal span collection to also remove
@Injectablewhen it coexists with a primary decorator, and adds regression tests covering@Pipe+@Injectable(both orders) plus@Component/@Directive/@NgModule+@Injectablecombinations.Written by Cursor Bugbot for commit fdbbfd7. This will update automatically on new commits. Configure here.