Skip to content

fix: compile @Injectable with coexisting PRIMARY decorators on the same class#75

Merged
Brooooooklyn merged 1 commit intomainfrom
fix/injectable-shared-precedence-decorator-coexistence
Mar 5, 2026
Merged

fix: compile @Injectable with coexisting PRIMARY decorators on the same class#75
Brooooooklyn merged 1 commit intomainfrom
fix/injectable-shared-precedence-decorator-coexistence

Conversation

@Brooooooklyn
Copy link
Member

@Brooooooklyn Brooooooklyn commented Mar 5, 2026

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:

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 HandlerPrecedence behavior so a class with a PRIMARY decorator (@Component, @Directive, @Pipe, @NgModule) and a SHARED @Injectable now emits both the primary definition (ɵcmp/ɵdir/ɵpipe/ɵmod/ɵinj) and an injectable static ɵprov, instead of only compiling whichever decorator matched the previous else if chain.

Updates decorator-removal span collection to also remove @Injectable when it coexists with a primary decorator, and adds regression tests covering @Pipe+@Injectable (both orders) plus @Component/@Directive/@NgModule+@Injectable combinations.

Written by Cursor Bugbot for commit fdbbfd7. This will update automatically on new commits. Configure here.

…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>
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Brooooooklyn Brooooooklyn merged commit 3796ddd into main Mar 5, 2026
4 checks passed
@Brooooooklyn Brooooooklyn deleted the fix/injectable-shared-precedence-decorator-coexistence branch March 5, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@Pipe + @Injectable on the same class: @Pipe decorator not compiled, causes JIT fallback

1 participant