This is because the sample class can be implicitly created from int . And so, when you specify <sample> as a type argument, int matches the first parameter of type <sample> , implicitly , but T2 then undefined because it can't be output to any type.
This does not happen in the second case, because then you partially specify the types: <sample> indicates the type T1 , and then int can be inferred for T2 , and the types of patterns are all inferred. Even if all types are not used, this is normal.
source share