Skip to content

Fix an issue where subcomponent factory method fails when defined with type parameters. - #5260

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_965438864
Aug 28, 2026
Merged

Fix an issue where subcomponent factory method fails when defined with type parameters.#5260
copybara-service[bot] merged 1 commit into
masterfrom
test_965438864

Conversation

@copybara-service

Copy link
Copy Markdown

Fix an issue where subcomponent factory method fails when defined with type parameters.

This CL updates BindingGraph.factoryMethodRequirements() to explicitly resolve the factory method's parameters against the parent component's concrete type using asMemberOf(parentType) to properly handle cases where a component might inherit from a generic interface.

For example,

@Component
interface Parent extends SubcomponentProvider<Child, ChildModule> {}

interface SubcomponentProvider<C, M> {
  C createSubcomponent(M module);
}

Previously, the compiler failed to resolve the parameter M to the concrete ChildModule type which leads to the following error:

java.lang.IllegalArgumentException
        at plugin.apt.turbine//com.google.common.base.Preconditions.checkArgument(Preconditions.java:136)
        at plugin.apt.turbine//dagger.internal.codegen.binding.ComponentRequirement.forModule(ComponentRequirement.java:190)
        at plugin.apt.turbine//dagger.internal.codegen.binding.BindingGraph.lambda$factoryMethodRequirements$0(BindingGraph.java:450)

RELNOTES=N/A

…h type parameters.

This CL updates `BindingGraph.factoryMethodRequirements()` to explicitly resolve the factory method's parameters against the parent component's concrete type using `asMemberOf(parentType)` to properly handle cases where a component might inherit from a generic interface.

For example,

```
@component
interface Parent extends SubcomponentProvider<Child, ChildModule> {}

interface SubcomponentProvider<C, M> {
  C createSubcomponent(M module);
}
```

Previously, the compiler failed to resolve the parameter `M` to the concrete `ChildModule` type which leads to the following error:

```
java.lang.IllegalArgumentException
        at plugin.apt.turbine//com.google.common.base.Preconditions.checkArgument(Preconditions.java:136)
        at plugin.apt.turbine//dagger.internal.codegen.binding.ComponentRequirement.forModule(ComponentRequirement.java:190)
        at plugin.apt.turbine//dagger.internal.codegen.binding.BindingGraph.lambda$factoryMethodRequirements$0(BindingGraph.java:450)
```

RELNOTES=N/A
PiperOrigin-RevId: 972676784
@copybara-service
copybara-service Bot merged commit 4fbc045 into master Aug 28, 2026
7 checks passed
@copybara-service
copybara-service Bot deleted the test_965438864 branch August 28, 2026 17:55
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.

1 participant