Open
Description
Typical example:
public interface CtNamedElement extends CtElement {
<T extends CtNamedElement> 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.