Parametrized methods where type parameter is used only in return type should be removed
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
Typical example:
```java
public interface CtNamedElement extends CtElement {
T setSimpleName(String simpleName);
}
```
Type parameter `T` is used only in method's return type, not in the parameters.
It doesn't make sense in Java. If this method is defined in the interface (like `CtNamedElement`), it should just be declared to return `CtNamedElement`. Implementations in overriding classes narrow the return type to their actual type.
Why this is bad: it contaminates API usage from Kotlin, because type parameter couldn't be derived automatically and should always be specified.
Contributor guide
Research direction
Start by locating CtNamedElement and reviewing its setSimpleName declaration, then search for other methods whose type parameter appears only in the return type. Check how overriding implementations narrow return types and review the existing issue discussion before changing the API. Done means these unnecessary interface type parameters are removed without losing valid covariant return types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100