-
Bug
-
Resolution: Fixed
-
P5
-
5.0
-
b03
-
generic, x86
-
solaris_8, windows_xp
-
Verified
I'm trying to understand the compiler behavior in this case:
class M<T> {}
class Main {
static <T extends M<U>, U> void f1() {
}
void g(M m1) {
f1();
}
}
when I compile this I get
H.java:6: incompatible types; inferred type argument(s) M<U>,java.lang.Object do not conform to bounds of type variable(s) T,U
found : <T,U>void
required: void
f1();
^
This doesn't make sense. Why didn't it infer M<Object>,Object? What is this 'U' that appears in the argument to M in the error message? Is there a type substitution missing somewhere in the compiler?
Strangely, it still fails if I change the order of the formal type parameters, but with a different message altogether.
I think the compiler has to be able to handle this kind of code in order to be able to handle calls involving raw types (in the new overload resolution algorithm, raw types underconstrain the type parameters).
class M<T> {}
class Main {
static <T extends M<U>, U> void f1() {
}
void g(M m1) {
f1();
}
}
when I compile this I get
H.java:6: incompatible types; inferred type argument(s) M<U>,java.lang.Object do not conform to bounds of type variable(s) T,U
found : <T,U>void
required: void
f1();
^
This doesn't make sense. Why didn't it infer M<Object>,Object? What is this 'U' that appears in the argument to M in the error message? Is there a type substitution missing somewhere in the compiler?
Strangely, it still fails if I change the order of the formal type parameters, but with a different message altogether.
I think the compiler has to be able to handle this kind of code in order to be able to handle calls involving raw types (in the new overload resolution algorithm, raw types underconstrain the type parameters).