-
Enhancement
-
Resolution: Unresolved
-
P4
-
5.0, 7, 8
-
Fix Understood
-
generic
-
generic
In:
static <T> T choose(boolean b, T trueValue, T falseValue) {
return b ? trueValue : falseValue;
}
boolean b = false;
List<? super Number> s = null;
s = b ? s : s;
s = choose(b, s, s);
Inference can't handle lower/super bounded wildcards leading to errors like:
Choose.java:10: incompatible types
found : java.util.List<capture of ? extends java.lang.Object>
required: java.util.List<? super java.lang.Number>
s = b ? s : s;
^
Choose.java:11: incompatible types
found : java.util.List<capture of ? extends java.lang.Object>
required: java.util.List<? super java.lang.Number>
s = choose(b, s, s);
^
See the attached file Choose.java
###@###.### 2004-05-25
static <T> T choose(boolean b, T trueValue, T falseValue) {
return b ? trueValue : falseValue;
}
boolean b = false;
List<? super Number> s = null;
s = b ? s : s;
s = choose(b, s, s);
Inference can't handle lower/super bounded wildcards leading to errors like:
Choose.java:10: incompatible types
found : java.util.List<capture of ? extends java.lang.Object>
required: java.util.List<? super java.lang.Number>
s = b ? s : s;
^
Choose.java:11: incompatible types
found : java.util.List<capture of ? extends java.lang.Object>
required: java.util.List<? super java.lang.Number>
s = choose(b, s, s);
^
See the attached file Choose.java
###@###.### 2004-05-25
- duplicates
-
JDK-6573446 javac infers a type bound where none should exist
- Closed
- relates to
-
JDK-8059898 4.10.4: lub incorrect for '? extends T', '? super T' combination
- Closed
-
JDK-8068542 18.4: Improve resolution where lub is incompatible with an upper bound
- Open
-
JDK-6480391 Unbounded wildcard '?' means '? extends Object'
- Closed
-
JDK-8073129 The result of lub(C<U>, C<? super V>) is incorrect
- Open
-
JDK-8061427 Type variables should have lower/super bounds
- Closed
(1 relates to)