FULL PRODUCT VERSION :
javac 1.6.0_14-b08)
ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.18-92.1.22.el5
Mac OS X 10.5.6
A DESCRIPTION OF THE PROBLEM :
I get an unchecked warning when an assignment conversion from a non-parameterized local class type to a parameterized supertype occurs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the program below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should compile without warning.
ACTUAL -
Produces an unchecked warning. Note that only the local class type leads to a warning; the identical member class does not cause a warning.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
NoTypeArg.java:8: warning: [unchecked] unchecked conversion
found : Instance2
required: NoTypeArg.Foo<T>
f = new Instance2(); // unchecked warning
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class NoTypeArg<T> {
interface Foo<T> {}
class Instance1 implements Foo<T> {}
public void method() {
class Instance2 implements Foo<T> {}
Foo<T> f;
f = new Instance1(); // no problem
f = new Instance2(); // unchecked warning
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use a SuppressWarnings tag, or a previous compiler.