google / google/auto

Support overriding factory methods that come from generic superclasses/interfaces.

Open
#54 1 comment 0 reactions 0 assignees View on GitHub
Component: factory P3 type=defect
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

When a factory method is inherited from a generic class/interface, generated auto factory will use type parameter name (e.g. T) rather than the substituted type. For example, given this code:

```
class MyClass {

@AutoFactory(implementing = MyFactory.class)
MyClass(@Provided String s, Integer i) {}

interface MyFactory
extends GenericFactory {}

interface GenericFactory {
T make(S arg);
}
}
```

Generated factory will contain this method

```
public MyClass make(S arg) {
return create(arg);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.