-
Bug
-
Resolution: Cannot Reproduce
-
P5
-
None
-
6
-
generic
-
generic
FULL PRODUCT VERSION :
javac 1.6.0-beta2
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The testcase included with this report yields an error when compiled.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply compile the source with javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected that Integer would have been correctly inferred as the type for the NaturallySortedCollection returned by empty(), as it is-a Comparable<Integer>, which qualifies as a Comparable<? super Integer>.
ACTUAL -
Compile error shown below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
C:\java\jaggregate-trunk\example-src\foo\InferenceExample.java:12: incompatible types; no instance(s) of type variable(s) T exist so that foo.NaturallySortedCollection<T> conforms to foo.NaturallySortedCollection<java.lang.Integer>
found : <T>foo.NaturallySortedCollection<T>
required: foo.NaturallySortedCollection<java.lang.Integer>
final NaturallySortedCollection<Integer> digits = empty();
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package foo;
import static foo.NaturallySortedCollection.empty;
class NaturallySortedCollection<E extends Comparable<? super E>> {
static <T extends Comparable<? super T>> NaturallySortedCollection<T> empty() {
return new NaturallySortedCollection<T>();
}
}
class InferenceExample {
public static void main( final String[] args ) {
final NaturallySortedCollection<Integer> digits = empty();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Provide an explicit type argument of <Integer> to the invocation of empty().
javac 1.6.0-beta2
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b86)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b86, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The testcase included with this report yields an error when compiled.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply compile the source with javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected that Integer would have been correctly inferred as the type for the NaturallySortedCollection returned by empty(), as it is-a Comparable<Integer>, which qualifies as a Comparable<? super Integer>.
ACTUAL -
Compile error shown below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
C:\java\jaggregate-trunk\example-src\foo\InferenceExample.java:12: incompatible types; no instance(s) of type variable(s) T exist so that foo.NaturallySortedCollection<T> conforms to foo.NaturallySortedCollection<java.lang.Integer>
found : <T>foo.NaturallySortedCollection<T>
required: foo.NaturallySortedCollection<java.lang.Integer>
final NaturallySortedCollection<Integer> digits = empty();
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package foo;
import static foo.NaturallySortedCollection.empty;
class NaturallySortedCollection<E extends Comparable<? super E>> {
static <T extends Comparable<? super T>> NaturallySortedCollection<T> empty() {
return new NaturallySortedCollection<T>();
}
}
class InferenceExample {
public static void main( final String[] args ) {
final NaturallySortedCollection<Integer> digits = empty();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Provide an explicit type argument of <Integer> to the invocation of empty().
- duplicates
-
JDK-6497707 Problem with underconstrained type variable and super bounded wildcards
- Closed
- relates to
-
JDK-6369605 Unconstrained type variables fails to include bounds
- Closed