EVALUATION
The submitter is right. Class x is not well-formed because the method signatures have the same erasure. Return type is not part of a signature, even though a return type should be erased at the same time as a signature (see 6730568).
For the record, given:
class x {
int f(List<String> l) {return 0;}
double f(List<Integer> l) {return 0;}
}
- f(List<String>) is not the same signature as f(List<Integer>).
- Then, f(List<String>) is not a subsignature of f(List<Integer>), because f(List<String>) does not have the same signature as f(List<Integer>) nor is f(List<String>) the same as the erasure of f(List<Integer>).
- Similarly, f(List<Integer>) is not a subsignature of f(List<String>).
- Thus they are not override-equivalent, which makes sense because you would never want to override f(List<Integer>) with f(List<String>).
- By 8.4.8.3, a compile-time error should occur because:
- both methods have the same name
- both are trivially accessible from x
- the signature of f(List<String>) is not a subsignature of f(List<Integer>) (or vice-versa)
- f(List<String>) has the same erasure as f(List<Integer>)
8.4.8.3 should be clarified to say: "***the signature of*** m1 or some other method...has the same erasure as ***the signature of m2*** or some other method...".
|