Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION service member referenced in an Angular external template is reported…

  1. User

    ISSUE DESCRIPTION

    service member referenced in an Angular external template is reported as unused when the component property is initialized with inject() (no explicit type annotation)

    What happened?

    With the angular plugin active, fallow dead-code reports a service method as an unused class member when its only reference is in an Angular HTML template (prop.method()), and the component property prop is initialized with the modern inject() pattern without an explicit type annotation:

    readonly exampleService = inject(ExampleService);
    

    Fallow already credits template references through component properties for the other three DI/instance patterns — it is specifically the untyped inject() initializer that is missed. The following all resolve correctly (no false positive); only the last one fails:

    Component property patternTemplate prop.method() resolved?
    constructor(public svc: ExampleService) {}✅ yes
    svc: ExampleService = inject(ExampleService); (typed)✅ yes
    svc = new ExampleService();✅ yes
    svc = inject(ExampleService); (untyped)❌ no — false positive

    Because untyped inject() is the idiomatic Angular style, this misfires on a very common real-world pattern.

    Reproduction

    Minimal standalone repro. @angular/core only needs to be listed in package.json so the angular plugin auto-activates — running npm install is optional (without it, fallow prints a "node_modules directory not found" warning but the finding still reproduces).

    1. Create package.json:

      {
        "name": "fallow-angular-template-repro",
        "version": "1.0.0",
        "private": true,
        "dependencies": {
          "@angular/core": "^20.0.0"
        }
      }
      
    2. Create .fallowrc.json:

      {
        "entry": ["src/main.ts"]
      }
      
    3. Create src/main.ts:

      import { ExampleComponent } from './example.component';
      
      console.log(ExampleComponent);
      
    4. Create src/example.service.ts:

      import { Injectable } from '@angular/core';
      
      @Injectable({ providedIn: 'root' })
      export class ExampleService {
        // Only referenced from example.component.html via an event binding.
        onValueChange(value: string): void {
          console.log(value);
        }
      }
      
    5. Create src/example.component.ts:

      import { Component, inject } from '@angular/core';
      
      import { ExampleService } from './example.service';
      
      @Component({
        selector: 'app-example',
        templateUrl: './example.component.html',
      })
      export class ExampleComponent {
        // Exposed to the template so the binding can call exampleService.onValueChange(...)
        readonly exampleService = inject(ExampleService);
      }
      
    6. Create src/example.component.html:

      <input (input)="exampleService.onValueChange($event.target.value)" />
      
    7. Run:

      npx fallow dead-code --config .fallowrc.json
      

    Actual output

    ── Unused Code ─────────────────────────────────────
    
    ● Unused class members (1)
      src/example.service.ts
        :6 ExampleService.onValueChange
      Class methods or properties never referenced outside their class
    
    ✗ 1 class member
    

    onValueChange is reported as unused even though it is referenced in example.component.html.

    Controls that isolate the root cause

    Keeping the template (input)="exampleService.onValueChange(...)" unchanged and only varying how exampleService is declared on the component:

    • Control A — constructor injection: replace the inject() field with constructor(public exampleService: ExampleService) {}. Result: ✓ No issues found.
    • Control B — inject() with an explicit type annotation: readonly exampleService: ExampleService = inject(ExampleService);. Result: ✓ No issues found.
    • Control C — new initializer: readonly exampleService = new ExampleService();. Result: ✓ No issues found.

    Only the untyped inject() initializer (the repro above) produces the false positive. This points at the component-property → service-type binding step: it resolves type annotations, constructor parameters, and new expressions, but not an untyped inject() initializer, so the template reference exampleService.onValueChange is never credited to ExampleService.

    Expected behavior

    A service member referenced from an Angular template via a component property should be credited as used when that property is initialized with inject() — the same way it already is for typed inject(), constructor injection, and new initializers. No unused-class-member finding should be reported in the repro above.

    Fallow version

    fallow 2.83.0

    Operating system

    macOS

    Configuration

    default
    

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /fallow, current file: none) bash-$

  2. MiniMax Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. MiniMax Assistant

    Now let me look at the unused_members.rs file specifically in the area where the angular template ref logic is:

  4. MiniMax Assistant

    Now let's look at where the instance_bindings are extracted:

  5. MiniMax Assistant

    Found it! The extract_class_instance_bindings function handles:

    1. Constructor parameter with type annotation (public, private, etc.)
    2. PropertyDefinition with type annotation (prop: Foo = ...)
    3. PropertyDefinition with new Foo() expression

    But it does NOT handle the case where inject(Foo) is used. Let me check the related parts to understand more:

  6. MiniMax Assistant

    Now let me look at the extract_class_instance_bindings to understand the structure better and find where to add inject handling:

  7. MiniMax Assistant

    Now let me check existing tests to understand the patterns being tested:

  8. MiniMax Assistant

    Let me also look at the CallExpression handling for inject:

  9. MiniMax Assistant

    Now let me understand the imports and the structure of the helpers module better:

  10. MiniMax Assistant

    Now let me look at the actual test cases that test injection patterns:

  11. MiniMax Assistant

    Now let me look at the visit_impl.rs to see where inject is referenced:

  12. MiniMax Assistant

    Now let me see how this is used at line 1886:

  13. MiniMax Assistant

    Now I have a clear picture. The extract_class_instance_bindings function in helpers.rs needs to be updated to also handle inject(Foo) call expressions. Let me look at the part again:

  14. MiniMax Assistant

    Now let me check what extract_angular_inject_target looks like and how it's defined:

  15. MiniMax Assistant

    Now let me see how extract_class_instance_bindings is called and how it interacts with the visitor:

  16. MiniMax Assistant

    Now let me understand the chain better by looking at the binding target flow:

  17. MiniMax Assistant

    Now let me look at the test for the existing angular-inject-class-members fixture to see what's already working:

  18. MiniMax Assistant

    Now I understand the issue. The fix needs to update extract_class_instance_bindings to also handle inject() calls. Let me first reproduce the issue:

  19. MiniMax Assistant

    Issue is reproduced. Now let me understand exactly where the fix needs to happen. Looking at the code:

  20. MiniMax Assistant

    Now I understand. The function extract_class_instance_bindings (in helpers.rs) needs to:

    1. Check if the property is private (already does)
    2. Check for type annotation (already does)
    3. Check for new Foo() (already does)
    4. NEED TO ADD: Check for inject(Foo) from @angular/core

    But extract_angular_inject_target is a method on the visitor itself, while extract_class_instance_bindings is a free function. Let me look at the visitor method again:

  21. MiniMax Assistant

    Now I see the pattern. The visitor does it through extract_angular_inject_target which has access to is_named_import_from. Let me see how is_named_import_from is implemented:

  22. MiniMax Assistant

    Now let me check what ImportedName looks like:

  23. MiniMax Assistant

    Now let me understand how extract_class_instance_bindings is invoked. The visitor method has access to imports so it knows about @angular/core. The helper function does not. Let me look at the call sites:

  24. MiniMax Assistant

    Let me also look at how binding_target_names is used in the visit_property_definition to understand the existing fix:

  25. MiniMax Assistant

    Now I understand the architecture. The visitor visit_property_definition already handles inject(Foo) for setting binding_target_names (used by this.inner.aaa resolution). But extract_class_instance_bindings is the free function that produces the instance_bindings used for class heritage. The two code paths are separate.

    Let me understand how binding_target_names differs from instance_bindings:

  26. MiniMax Assistant

    So binding_target_names is what enables this.inner.aaa to resolve to InnerService.aaa. And extract_class_instance_bindings produces the instance_bindings in class_heritage, which is used for resolving component template references like exampleService.method() to ExampleService.method.

    The fix is to update extract_class_instance_bindings to also handle inject() calls. The function is called from:

    1. visit_declaration (line 1953)
    2. visit_export_default_declaration (line 2235)
    3. declarations.rs line 61

    In all cases, the visitor state (specifically imports) is not directly passed to extract_class_instance_bindings. Let me see what's the cleanest approach:

  27. MiniMax Assistant

    Now let me understand more about how inject() is detected and how it can be applied without the import context. Let me check the visitor's extract_angular_inject_target:

    The key insight from the test:

    #[test]
    fn non_angular_inject_function_does_not_map_field_member_access() {
        // ...
        import { inject } from './container';
        // ...
        assert!(
            !info.member_accesses.iter().any(|a| a.object == "InnerService" && a.member == "aaa"),
            "non-Angular inject() should not create class-member credit"
        );
    }
    

    So inject() from any other module (not @angular/core) should NOT be mapped. This means we need access to the imports to verify it's from @angular/core.

    Let me see how to pass the imports. Let me look at the simplest approach - refactor extract_class_instance_bindings to optionally take an is_angular_inject predicate function:

  28. MiniMax Assistant

    Now let me look at how the inject test works for typed inject to see how that is resolved currently:

  29. MiniMax Assistant

    Now I need to understand how record_typed_binding works to learn the pattern:

  30. MiniMax Assistant

    Now I have enough context. The approach I'll take is:

    Solution Plan:

    The fix should be in extract_class_instance_bindings in crates/extract/src/visitor/helpers.rs. We need to add detection of inject(Service) calls from @angular/core.

    Looking at the current implementation:

    1. It currently extracts: constructor params with type annotation, getters with type annotation, property definitions with type annotation, and new Foo() calls.
    2. It does NOT handle inject(Foo) from @angular/core.

    The simplest fix: modify extract_class_instance_bindings to also handle the case where the property value is inject(SomeService). To check that the function is inject from @angular/core, we need access to the imports.

    Let me modify the approach - pass an optional closure that checks for the Angular inject function:

    Actually, looking more carefully, the cleanest approach is to:

    1. Add a new function extract_angular_inject_target_from_call(call, is_angular_inject) (a free function that takes a predicate)
    2. Modify extract_class_instance_bindings to accept a similar predicate and use it for inject() detection.

    Let me look more at the visitor structure first to find the cleanest refactor:

  31. MiniMax Assistant

    Now let me find a simpler approach. Looking at the test for the inject pattern that's already being correctly handled by binding_target_names:

    fn extract_angular_inject_target(&self, call: &CallExpression<'_>) -> Option<String>
    

    This is in the visitor itself. The same logic can be applied in the helper. Let me check how is_named_import_from accesses self.imports. I want to refactor this so the helper function gets the imports info.

    Actually, the cleanest way would be to:

    1. Extract the inject() call detection logic into a free function that accepts the imports.
    2. Modify extract_class_instance_bindings to accept the imports (or accept a closure).

    Let me first take the simpler approach: make extract_class_instance_bindings accept an optional is_angular_inject predicate.

  32. MiniMax Assistant

    Now let me look at how type_name_root is used and the imports of helpers.rs to understand what I have access to:

  33. MiniMax Assistant

    Now let me look at the existing imports in helpers.rs to see what's available there:

  34. MiniMax Assistant

    OK, the helper file doesn't have access to TSTypeReference import. Let me approach this differently.

    Let me think about the cleanest approach. I have two options:

    1. Pass a closure / predicate to extract_class_instance_bindings that determines if a call expression is an Angular inject() call.
    2. Refactor to make extract_class_instance_bindings accept a struct of dependencies.

    Option 1 is the simplest. Let me implement it:

    Now let me look at what type_name_root returns and the CallExpression structure:

  35. MiniMax Assistant

    Good, TSTypeReference is accessible through TSType::TSTypeReference. Now let me think about this more carefully.

    The most elegant solution: change the signature of extract_class_instance_bindings to take an optional Fn(&CallExpression) -> Option<String> predicate that returns the type name if the call is an Angular inject() call. The caller (visitor) can pass a closure that uses is_named_import_from.

    Actually, an even cleaner approach: just pass the imports as a parameter. But that's a bigger refactor.

    Let me implement option 1 - take a predicate:

  36. MiniMax Assistant

    I need to add CallExpression to the imports. Let me look at what oxc exposes:

  37. MiniMax Assistant

    OK, CallExpression is available. Let me check how the visit_impl handles the inject target:

  38. MiniMax Assistant

    Now I'll implement the fix. My approach:

    1. Modify extract_class_instance_bindings to take a generic parameter that can be a function-like closure detecting Angular inject().
    2. Update the 3 call sites.

    Actually, the simplest approach is to use a trait-based abstraction or to simply add a parameter that takes a closure. Let me go with the closure approach using Fn:

  39. MiniMax Assistant

    Let me think again. The cleanest approach would actually be to:

    1. Make extract_class_instance_bindings take a generic predicate parameter (a closure Fn(&CallExpression) -> Option<String>).
    2. Update all 3 call sites to pass |_| None for backwards compatibility OR pass the visitor-specific closure.

    Wait, looking at this more carefully, extract_class_instance_bindings is only ever called from within the visitor. Let me check if there's any other call site:

  40. MiniMax Assistant

    All call sites are in the visitor. So I can simply pass a closure from each of these. Let me design the API:

    pub fn extract_class_instance_bindings<F>(
        class: &Class<'_>,
        angular_inject_target: F,
    ) -> Vec<(String, String)>
    where
        F: Fn(&CallExpression<'_>) -> Option<String>,
    

    Let me implement this now:

  41. MiniMax Assistant

    Now I need to update the imports and refactor. Let me also check how the existing function handles type_arguments:

  42. MiniMax Assistant

    Good - call.type_arguments is accessible directly. Now let me implement the fix:

  43. MiniMax Assistant

    Wait, I need to also look at the case of typed inject() since the issue says that one already works:

    svc: ExampleService = inject(ExampleService);
    

    This works because the type annotation svc: ExampleService is detected. The problem is only when there's no type annotation:

    svc = inject(ExampleService);
    

    OK, so I need to add an else if branch after the new branch that detects inject() calls. Let me also note that the if let Some(Expression::NewExpression(...)) has a continue missing - actually no, it does fall through to the end of the match. Let me also check that I follow the same pattern.

    Looking at the existing logic more carefully:

    1. Type annotation present → use type annotation, continue (skip new/inject detection)
    2. New expression → record
    3. (implicit) Fall through to nothing

    I need to add: CallExpression that is inject(Service) from @angular/core.

    But there's a subtle issue: the current code does NOT continue after detecting the NewExpression. Let me check if that's intentional... actually it does fall through because it's an if let without else if, so we should add the new condition as an else if or another independent if let.

    Let me apply the fix now:

  44. MiniMax Assistant

    Now I notice one issue. Looking at the existing code:

    • When new is detected, it does NOT continue. This is because the next if let is for CallExpression, which won't match a NewExpression anyway. So the lack of continue doesn't matter.

    But to be safe and clear, let me add continue to the new branch (so we don't accidentally match inject() on a new).

    Actually wait, in the existing code, the new branch and inject branch are different patterns (NewExpression vs CallExpression), so they won't overlap. But I'll add continue for cleanliness.

    Now let me apply the change:

  45. MiniMax Assistant

    Now let me apply the fix using the edit command:

  46. MiniMax Assistant

    Now I'll apply the fix using edit:

  47. MiniMax Assistant

    Let me apply the fix using the edit command.

  48. MiniMax Assistant

    The edit looks good. Now I need to update the call sites. Let me update them:

  49. MiniMax Assistant

    Now I'll update the call site in visit_impl.rs:

  50. MiniMax Assistant

    I notice that the edit got messed up because the original lines started at 1952. Let me fix the issue:

  51. MiniMax Assistant

    Now let me update the second call site:

  52. MiniMax Assistant

    I see that my edit replaced 3 lines with 4 lines but missed the let is_angular = ... line. Let me fix that:

  53. MiniMax Assistant

    I see I have duplicated } else { block. Let me clean this up:

  54. MiniMax Assistant

    I have more cleanup to do - my edits have gotten the file structure messed up. Let me look at the current state and fix it:

  55. MiniMax Assistant

    Let me fix this entire broken section:

  56. MiniMax Assistant

    Now let me add the missing blank line between the functions:

  57. MiniMax Assistant

    Hmm, my edits have made it worse - there's a duplicate } and missing let (members, super_class, ...) line. Let me use git to restore:

  58. MiniMax Assistant

    Let me revert visit_impl.rs and reapply the changes more carefully:

  59. MiniMax Assistant

    Good, the helpers.rs change is intact. Now let me update the visit_impl.rs call sites one at a time more carefully. First, let me see the current state:

  60. MiniMax Assistant

    Now let me update the second call site:

  61. MiniMax Assistant

    Now let me update the third call site (in declarations.rs):

  62. MiniMax Assistant

    I see that CallExpression is already imported in declarations.rs. Let me update the call site:

  63. MiniMax Assistant

    Wait, but extract_angular_inject_target is defined on ModuleInfoExtractor (the visitor struct). Let me check if it's accessible from declarations.rs:

  64. MiniMax Assistant

    Since both declarations.rs and visit_impl.rs are in the same visitor module and extract_angular_inject_target is defined as a method on ModuleInfoExtractor in visit_impl.rs, it should be accessible. Let me verify:

  65. MiniMax Assistant

    extract_angular_inject_target is defined at line 1637, which is within the impl<'a> Visit<'a> for ModuleInfoExtractor block. Let me check if it's accessible from declarations.rs. Since they're both methods on the same ModuleInfoExtractor struct, the answer should be yes.

    Let me build to check:

  66. MiniMax Assistant

    I need to make it public (or pub(crate)). Let me change it to pub(crate):

  67. MiniMax Assistant

    Now let me try to build again:

  68. MiniMax Assistant

    Let me run the reproduction again:

  69. MiniMax Assistant

    Hmm, the issue is still happening. Let me investigate - maybe my changes don't actually get applied or the test setup doesn't exercise them. Let me check the template ref resolution path again:

  70. MiniMax Assistant

    Now let me trace through this. We need:

    1. angular_tpl_chain_accesses to contain (exampleService, onValueChange) from the example.component.ts file
    2. class_heritage_by_file for example.component.ts to have instance_bindings: [("exampleService", "ExampleService")]

    Let me check that the second part is now happening. Let me look at the issue more carefully by adding some debug output:

    Wait, I realize the issue! The chain accesses happen from the resolved import module (the template HTML file is processed via extract_angular_tpl_chain_accesses). But the template exampleService.onValueChange is processed against the component file. Let me look at the angular_tpl_chain_accesses logic again:

  71. MiniMax Assistant

    Now I see - the template url itself adds an import (a side-effect import), but the template references are added to member_accesses of the same file (the component file) as ANGULAR_TPL_SENTINEL accesses.

    Let me trace this more carefully. In the component file:

    • The template is added as a SideEffect import (the templateUrl)
    • The template references are added to member_accesses for the same file (component file)

    So in unused_members.rs, when we look at resolved_modules:

    • angular_tpl_chain_accesses for the component file should contain ("exampleService", "onValueChange")
    • class_heritage_by_file for the component file should contain instance_bindings: [("exampleService", "ExampleService")]

    Let me check how the templateUrl is processed:

  72. MiniMax Assistant

    Hmm, so for an external template URL, the template is NOT processed for refs. The refs are only collected for inline templates. The template_url only registers an import. So the template reference detection must work via the html parser. Let me check:

  73. MiniMax Assistant

    So when the HTML file is parsed, its template refs are added as member accesses with ANGULAR_TPL_SENTINEL. But these refs are stored on the HTML file's ModuleInfo, NOT the component file's ModuleInfo.

    Then in unused_members.rs:

    • angular_tpl_chain_accesses iterates over resolved_modules (which includes both .ts and .html files)
    • For each ResolvedModule, if it has a sentinel access, it collects the chain accesses
    • Then it iterates over resolved modules and looks at their class_heritage_by_file
    • For each resolved module, for each resolved import whose target is the file with chain accesses, it applies the bindings

    So:

    • The HTML file example.component.html has the chain accesses (with ANGULAR_TPL_SENTINEL sentinel)
    • The component file example.component.ts should have the class_heritage with instance_bindings: [("exampleService", "ExampleService")]
    • The component file imports the HTML file (via templateUrl)

    Let me re-read the unused_members.rs logic:

  74. MiniMax Assistant

    OK so class_heritage_by_file is the mapping of FileId -> &[ClassHeritageInfo]. The component file's class_heritage should have instance_bindings.

    Now my fix should have made this happen. Let me debug - maybe the issue is that extract_angular_inject_target is not being called properly. Let me add a quick debug test:

    Wait, let me first verify the fix is actually applied:

  75. MiniMax Assistant

    OK the helpers.rs has my fix. Now let me check the call sites in visit_impl.rs:

  76. MiniMax Assistant

    OK, the changes are in place. Let me trace through more carefully. Let me add a debug print to see what's happening:

    Actually, let me look at how the test for angular-inject-class-members works since it does work (the existing fixture passes):

  77. MiniMax Assistant

    This fixture uses this.inner.aaa - the existing fix for binding_target_names already handles this. The template url case is different. Let me trace the call path for the component class:

  78. MiniMax Assistant

    Now let me understand the relationship between visit_class and visit_declaration:

  79. MiniMax Assistant

    OK, I see the structure now. Let me find how visit_class is called:

  80. MiniMax Assistant

    Hmm, the only visit_class is the one I see. It's the AST visitor. Now visit_declaration is also called from the AST visitor. So we have two paths:

    1. visit_class - runs the AST walk, adds template URLs as imports
    2. visit_declaration for ClassDeclaration - extracts class members and instance bindings

    Both should be called for the same class. Let me check the order by looking at how walk::walk_class calls things:

  81. MiniMax Assistant

    Now walk::walk_declaration(self, decl) for a class would call walk_class, which would call our overridden visit_class. So visit_declaration is called first, then visit_class.

    Now let me check the issue more carefully. When visit_declaration is called for our component, it has self.imports populated with whatever has been processed so far. Let me look at what has been processed before:

  82. MiniMax Assistant

    OK so imports are pushed when visiting the import statements. Since visit_declaration for the class is called AFTER visit_import_declaration, the imports are already populated by the time we call extract_class_instance_bindings. So my fix should work...

    Let me try adding some debug output to see what's happening:

  83. MiniMax Assistant

    Actually, let me first run the existing tests to make sure my fix doesn't break anything:

  84. MiniMax Assistant

    All extract tests pass. Now let me test the integration test for the inject fixture:

  85. MiniMax Assistant

    The test passes. Now let me re-check the reproduction - I need to make sure my changes are actually applied to the binary:

  86. MiniMax Assistant

    Still failing. Let me trace more carefully. Let me check if extract_class_instance_bindings is actually being called for the component class:

  87. MiniMax Assistant

    The issue still exists. Let me debug by checking if the issue is in the unused_members.rs flow or in the extract_class_instance_bindings flow. Let me add a debug print:

  88. MiniMax Assistant

    Let me add a quick debug print to see if the binding is being created:

  89. MiniMax Assistant

    Let me add a debug eprintln to trace what's happening:

  90. MiniMax Assistant

    I see I made a mess - the new code got inserted in the wrong place. Let me revert and apply more carefully:

  91. MiniMax Assistant

    Now let me apply the fix more carefully:

  92. MiniMax Assistant

    Now I need to add the inject call detection after the new expression detection:

  93. MiniMax Assistant

    I see - I lost the closing braces! The replacement removed the closing } of ClassElement::PropertyDefinition arm and the match and the for. Let me fix this:

  94. MiniMax Assistant

    Now let me verify the build works:

  95. MiniMax Assistant

    Now let me test the reproduction:

  96. MiniMax Assistant

    Still failing. Let me add a debug eprintln to see what's happening:

  97. MiniMax Assistant

    The DEBUG message didn't print. That means the extract_class_instance_bindings function isn't being called for our ExampleComponent. Let me check the visitor path:

  98. MiniMax Assistant

    Debug print is there but didn't fire. Let me check the debug at the function entry point:

  99. MiniMax Assistant

    I made a mess again. Let me revert and start fresh:

  100. MiniMax Assistant

    Now let me carefully apply the change using a single edit:

  101. MiniMax Assistant

    Now let me add the inject call detection:

  102. MiniMax Assistant

    Now let me build and check:

  103. MiniMax Assistant

    Still failing. Let me add an eprintln to understand:

  104. MiniMax Assistant

    The debug print is not appearing at all. This means extract_class_instance_bindings isn't being called for the ExampleComponent. Let me look at the call site flow:

  105. MiniMax Assistant

    Let me check whether there is something I'm missing about the visit_declaration path. Maybe the component class is processed via extract_declaration_exports:

  106. MiniMax Assistant

    extract_declaration_exports is called from visit_export_named_declaration (for export class Foo {...}). The ExampleComponent is exported, so this path would be taken. Let me add debug print there:

  107. MiniMax Assistant

    Let me add debug here:

  108. MiniMax Assistant

    The debug print doesn't fire! So neither declarations nor the helpers function is being called for the ExampleComponent. Let me check the visit_declaration path:

  109. MiniMax Assistant

    None of my debug prints are firing! This is strange. Maybe the module isn't being parsed. Let me try a different approach:

  110. MiniMax Assistant

    OK, the tool runs. Let me check if there's caching preventing rebuild:

  111. MiniMax Assistant

    The debug eprintln isn't being printed. This is weird. Maybe stderr is being suppressed? Let me check:

  112. MiniMax Assistant

    No debug output at all in stderr. So neither extract_class_instance_bindings nor visit_declaration are being called for the ExampleComponent. Let me check if the .ts files are even being processed:

  113. MiniMax Assistant

    Let me add an eprintln at the visitor entry point:

  114. MiniMax Assistant

    Let me add debug here:

  115. MiniMax Assistant

    Even visit_program debug doesn't fire! Something is really wrong. Let me check whether the binary is actually the new one:

  116. MiniMax Assistant

    The string is in the binary. So the binary is up to date. Why isn't it printing? Maybe the file is being cached or the analysis pipeline isn't even running. Let me look at the parse.rs to see where the visitor is used:

  117. MiniMax Assistant

    OK so the visitor is called. Let me add a debug print in parse_source_to_module_inner:

  118. MiniMax Assistant

    I duplicated the code. Let me revert:

  119. MiniMax Assistant

    Let me try with a sed approach to insert a single line:

  120. MiniMax Assistant

    Still no debug output. This means the file is being processed but somehow my debug isn't appearing. Wait - maybe parse_source_to_module_inner isn't even being called, because the files are being parsed by a different code path. Let me search:

  121. MiniMax Assistant

    There's a cache. Maybe the cache is preventing re-parsing. Let me look at it:

  122. MiniMax Assistant

    There's a cache! Let me find where the cache is stored:

  123. MiniMax Assistant

    Found the cache! Let me clear it and try again:

  124. MiniMax Assistant

    Excellent! The fix works! "✓ No issues found"! The cache was the issue. Let me clean up the debug prints and verify the fix:

  125. MiniMax Assistant

    Good. Now let me clean up the debug prints in other files:

  126. MiniMax Assistant

    Good, all debug prints removed. Now let me rebuild and test:

  127. MiniMax Assistant

    The fix works. Now let me check the other cases from the issue (A, B, C) to make sure they still work:

  128. MiniMax Assistant

    Control A still works. Now let's test Control B:

  129. MiniMax Assistant

    Control B still works. Let's test Control C:

  130. MiniMax Assistant

    Control C still works. Let me also test the original repro (untyped inject):

  131. MiniMax Assistant

    Now let me think about edge cases:

    1. Untyped inject(SomeService) from @angular/core - ✅ Fixed
    2. Untyped inject(SomeService) from non-@angular/core - Should NOT be treated as instance binding
    3. Untyped inject<T>(SomeService) with explicit type arg - Should be treated as instance binding
    4. Property assigned from inject() via constructor parameter
    5. inject(SomeService) on a private property - Should NOT be treated (private accessibility check)

    Let me test some of these edge cases. First, let me test that the non_angular_inject_function_does_not_map_field_member_access test still passes:

  132. MiniMax Assistant

    Now let me test some more edge cases manually:

  133. MiniMax Assistant

    Non-@angular/core inject() is correctly NOT mapped to instance binding. (The unresolved imports are because ./my-container doesn't exist, but that's not relevant.)

    Let me also test with inject<T>(Service) syntax:

  134. MiniMax Assistant

    Hmm, that works too because the existing extract_angular_inject_target already handles the <ExampleService> type argument. Let me confirm by looking at it again:

  135. MiniMax Assistant

    The function checks <ExampleService> first and then the identifier argument.

    Let me also test with private property to verify it doesn't create an instance binding:

  136. MiniMax Assistant

    usedInTemplate() is correctly NOT reported as unused (since it's used in the template), and unusedServiceMethod IS correctly reported. The fix is working as expected.

    Let me also verify the existing angular-inject-class-members fixture still passes:

  137. MiniMax Assistant

    Now let me run all tests to make sure I didn't break anything:

  138. MiniMax Assistant

    That test failure is unrelated to my fix. Let me verify:

  139. MiniMax Assistant

    Hmm, the test name was different. Let me try with my changes:

  140. MiniMax Assistant

    The test name might have been filtered out. Let me check:

  141. MiniMax Assistant

    The test passes when run in isolation. It's a flaky test or order-dependent test. Let me run all the tests for the extract and core crates to ensure I haven't broken anything:

  142. MiniMax Assistant

    All 641 core tests pass! Now let me also run the graph tests:

  143. MiniMax Assistant

    All 48 graph tests pass. Now let me also run the cli tests:

  144. MiniMax Assistant

    Let me check if this is unrelated:

  145. MiniMax Assistant

    Confirmed - the test failure is unrelated to my changes. It's a pre-existing issue (probably environment-specific since it tries to make a directory read-only, which doesn't work as root).

    Let me now run the full cli tests except for the failing one:

  146. MiniMax Assistant

    All 1830 lib tests pass. Now let me think about additional edge cases I should test:

    1. Property with both type annotation AND inject() initializer - should use type annotation (since it has higher priority in the existing code)
    2. Static property - should not create binding
    3. Method/constructor assignment with inject() - should not apply (only applies to PropertyDefinition)

    Let me look at the current code to verify:

  147. MiniMax Assistant

    The code only handles PropertyDefinition and not static properties. The static properties don't have static_name() returning their name in the same way. Let me check if there are static handling:

  148. MiniMax Assistant

    Static properties aren't explicitly excluded, but static_name() returns Some for both instance and static properties. The existing code doesn't filter for static, so my code doesn't either - which is consistent.

    Let me test the edge case where the type annotation AND inject() are both present:

  149. MiniMax Assistant

    The type annotation ExampleService is used. Both someMethod is correctly NOT reported (used in template). The other two methods are correctly reported as unused. So the type annotation takes priority.

    Let me also test the untyped inject with inject<ExampleService>():

  150. MiniMax Assistant

    Hmm! That's a problem. With inject<ExampleService>(ExampleService), the binding is NOT being created. Let me check the extract_angular_inject_target:

  151. MiniMax Assistant

    The function does check type_arguments first. Hmm, why isn't it returning "ExampleService"? Let me check the is_named_import_from - maybe the issue is that the file isn't being parsed correctly.

    Actually wait, the existing binding_target_names test for inject would have used the same code path. Let me re-run the original test:

  152. MiniMax Assistant

    Let me re-check the issue with inject<ExampleService>(ExampleService). Maybe the issue is the cache:

  153. MiniMax Assistant

    Still failing. Hmm. Let me add a debug eprintln to see what's happening:

  154. MiniMax Assistant

    Wait! Now it's working. Only 2 unused members are reported (anotherMethod and unusedServiceMethod), not all 3. The issue must have been the cache. Let me confirm with a fresh test of the original problem:

  155. MiniMax Assistant

    Working. Now let me also re-test the explicit type arg case:

  156. MiniMax Assistant

    Working too. The earlier failure was just due to caching - now with a clean cache, both forms work.

    Let me clean up the debug eprintln:

  157. MiniMax Assistant

    Now let me also look at if there's anything I should test with non-angular inject (my implementation correctly returns None from extract_angular_inject_target, so it's fine).

    Let me also consider this edge case: what if the same property has type annotation AND inject() but the type annotation is different? For example, prop: Foo = inject(Bar). The current code prefers the type annotation. Let me test:

  158. MiniMax Assistant

    With type annotation any, it's still no issue. That means the type annotation is used (which is "any") and not ExampleService. But since the property is template-accessible, the template can access it, so the unused member is correctly not reported.

    Wait, that's interesting. With : any, the template reference still works because the any is what's stored as the binding. Let me trace through:

    Actually, looking at the unused_members.rs code, the component_bindings is (exampleService, "any"). The template access exampleService.someMethod becomes (any, someMethod). The local_to_export_keys for "any" wouldn't match anything, so... let me re-check. Actually, the instance_bindings is processed by propagate_accesses_through_typed_instance_bindings. So even though "any" isn't a class, the access might still propagate through the bindings.

    Let me look more carefully:

  159. MiniMax Assistant

    This is for normal this.foo.bar() resolution. There's also the angular_tpl_chain_accesses logic that uses the class_heritage (which is the instance_bindings from my fix). Let me check what happens with any:

    In the angular_tpl_chain_accesses code, it uses component_bindings from class_heritage_by_file. If the type is any, then component_bindings is (exampleService, "any"). Then local_to_export_keys.get("any") returns None, so it doesn't propagate.

    But the test showed "No issues found"! That's strange. Let me check more carefully:

  160. MiniMax Assistant

    Yes, "No issues found". Maybe any has some special handling. Actually, that's because the type annotation any is probably treated as the un-typed case. Let me see what happens if I use a non-existent type:

  161. MiniMax Assistant

    OK now it reports the unused member. So with a non-existent type, the type annotation takes priority and the binding is not to ExampleService. The case of any must be specially handled somewhere in the extract_typed_bindings logic.

    Let me search for any handling:

  162. MiniMax Assistant

    No special handling for any. The "No issues found" for : any is a pre-existing behavior I shouldn't worry about. My fix doesn't affect it.

    Let me now also think about another edge case. What about when the inject() call is for a different module's inject?

    Actually, I already tested that - non-Angular inject() is correctly NOT mapped.

    Let me also think about: what if extract_angular_inject_target returns a type that's actually a generic type parameter? In the existing logic, it returns the name as-is, and resolve is then called. resolve would either keep it or replace it with the type param constraint. Let me check:

  163. MiniMax Assistant

    OK so the resolve closure will replace generic type params with their constraints, or pass through as-is. This is correct for inject() too.

    Now let me also test the case where inject is called with a generic that has a constraint:

  164. MiniMax Assistant

    SpecialService.specialMethod is correctly NOT reported (it's used via the template). Only BaseService is reported as unused export.

    Now let me also verify that a few other potentially related tests still pass. Let me run all extract tests:

  165. MiniMax Assistant

    All 1681 tests pass. Now let me write a new test for the specific issue we're fixing. Wait, the rules say I should not add new tests to the repository. Let me create a temporary test instead:

    Actually, looking at the task description:

    UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests to the repository.

    OK, I should not add new tests. The fix is verified by the existing tests passing and the reproduction case working.

    Let me also re-run the existing angular_inject integration test to confirm:

  166. MiniMax Assistant

    All angular tests pass! Let me also verify with a final check that the original repro still works:

  167. MiniMax Assistant

    The fix is working correctly. Let me do a final review of all my changes:

  168. MiniMax Assistant

    I see my sed command removed a comment line in visit_impl.rs. Let me restore that:

  169. MiniMax Assistant

    Now let me run cargo fmt and clippy to make sure the code is clean:

  170. MiniMax Assistant

    Let me run clippy:

  171. MiniMax Assistant

    Clippy suggests collapsing the if. Let me fix:

  172. MiniMax Assistant

    Clippy passes. Now let me also run cargo build to confirm:

  173. MiniMax Assistant

    Let me run the original reproduction one more time:

  174. MiniMax Assistant

    The fix is working correctly. Now let me do a final review:

  175. MiniMax Assistant

    The diff is clean. Let me also verify by looking at the final code:

  176. MiniMax Assistant

    The code looks clean. Let me run the entire test suite once more to be confident:

  177. MiniMax Assistant

    All 5389 tests pass across the extract, core, and graph crates. Let me check the cli tests too:

  178. MiniMax Assistant

    All 1830 lib tests in cli also pass. Let me also check the full test run for cli:

  179. MiniMax Assistant

    Only the fix_batch_aborts_when_a_target_directory_is_read_only test fails, and I already verified that's a pre-existing issue unrelated to my changes (it's a test that tries to make a directory read-only, which doesn't work as root).

    Let me verify by checking if this test also fails on the original code:

  180. MiniMax Assistant

    Confirmed - the test failure is pre-existing and unrelated to my changes.

    Let me now also remove the temporary repro folder:

  181. MiniMax Assistant

    Now let me do a final check of all my changes:

  182. MiniMax Assistant

    Now let me list the checklist:

    Checklist:

    • If an error was reported in the issue description, I have successfully reproduced it. - I successfully reproduced the issue. The error was a false positive reporting ExampleService.onValueChange as unused when the property is initialized with inject(ExampleService) (no type annotation).

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. - After my fix, the original repro now reports "✓ No issues found".

    • I have thought about edge cases and made sure my fix handles them as well. - I tested:

      • The original untyped inject(Service) case (the bug)
      • Control A: constructor injection (public svc: Service) - still works
      • Control B: typed inject (svc: Service = inject(Service)) - still works
      • Control C: new Service() initializer - still works
      • Non-@angular/core inject() - correctly NOT mapped (preserves existing behavior)
      • inject<Service>(Service) (explicit type arg) - correctly mapped
      • inject() with type annotation (combination) - type annotation takes priority
      • Inheritance hierarchies (BaseService/SpecialService)
      • Genuinely unused service methods still reported
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. - All existing tests in fallow-extract (1681), fallow-core (641), fallow-graph (48), and fallow-cli --lib (1830) pass. The only test that fails is a pre-existing test failure unrelated to my changes (test name: fix_batch_aborts_when_a_target_directory_is_read_only which fails because the test tries to set a directory as read-only, which doesn't work when running as root).

    Let me also do one more check that the fix is properly applied:

  183. MiniMax Assistant

    The diff is clean and focused. Let me now do one more final verification:

  184. MiniMax Assistant

    The fix is working correctly. The repro now reports "✓ No issues found" as expected.

    Let me clean up:

  185. MiniMax Assistant

    Now let me also check the final list of changes:

  186. MiniMax Assistant

    Summary

    Issue: The angular plugin's dead-code detector reports a service method as unused when it's only referenced from an external Angular HTML template (prop.method()), and the component property prop is initialized with the modern inject() pattern without an explicit type annotation (e.g., readonly exampleService = inject(ExampleService);).

    Root Cause: The extract_class_instance_bindings function in crates/extract/src/visitor/helpers.rs is responsible for extracting instance bindings from class members. It already handles:

    1. Constructor parameter properties with type annotations
    2. Getter methods with return type annotations
    3. Property definitions with type annotations
    4. Property definitions with new Foo() initializer

    But it was missing the inject(Foo) pattern (when there's no explicit type annotation). The visitor already had extract_angular_inject_target method that detects Angular inject() calls, but it was only used for binding_target_names (which handles this.field.method() accesses in code), not for instance_bindings (which handles template references like field.method() in HTML).

    Fix:

    1. Modified extract_class_instance_bindings in crates/extract/src/visitor/helpers.rs to accept a generic predicate F: Fn(&CallExpression<'_>) -> Option<String> that detects Angular inject() calls.
    2. Added a new branch in the function that detects inject(Foo) calls (after the existing new Foo() branch) and uses the predicate to extract the type name.
    3. Updated all 3 call sites to pass a closure that calls self.extract_angular_inject_target:
      • crates/extract/src/visitor/visit_impl.rs (2 call sites)
      • crates/extract/src/visitor/declarations.rs (1 call site)
    4. Made extract_angular_inject_target method pub(crate) so it can be called from declarations.rs (in the same module).

    The fix:

    • Resolves the original issue: untyped inject(Service) now creates the correct instance binding.
    • Maintains backward compatibility: all existing cases (constructor injection, typed inject, new initializer) still work.
    • Properly checks that the inject is from @angular/core (via the existing is_named_import_from check inside extract_angular_inject_target), so non-Angular inject() functions are not incorrectly mapped.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.