When you have a raw type in your code, all generic type information in that class is lost -- thus, the compiler does not know that someMethod
returns a List
of type String
.
The relevant portion of the JLS: Raw Types
The type of a constructor (§8.8), instance method (§8.4, §9.4), or non-static field (§8.3) M of a raw type C that is not inherited from its superclasses or superinterfaces is the raw type that corresponds to the erasure of its type in the generic declaration corresponding to C.
So since you declared the method parameter as SomeInterface
, which is a raw type, you cannot take advantage of the generic someMethod
, even though its generic type parameter is not the same as P
.