Files
Anna Kozlova 022c5be762 java type system: use captured wildcard bounds in cast context (IDEA-233551)
starting with javac 1.9+ such code starting to compile, javac 8 rejects the code with the same language level used

GitOrigin-RevId: 87a1e4d475927af0ee71cd74f5a66e130908ed82
2020-04-16 19:41:33 +00:00

35 lines
687 B
Java

class Test {
public <T> void foo(T valIn){
double val = (double ) valIn;
}
public <T extends Double> void foo1(T valIn){
double val = (double ) valIn;
}
public <T extends String> void foo2(T valIn){
double val = <error descr="Inconvertible types; cannot cast 'T' to 'double'">(double ) valIn</error>;
}
public <T extends S, S extends Double> void foo2(T valIn){
double val = (double ) valIn;
}
}
class Foo<T> {
private T _value;
T getValue() {
return _value;
}
static Foo<?> getFoo() {
return new Foo<>();
}
public static void main(String[] args) {
Foo<?> foo = getFoo();
double value = (double) foo.getValue();
}
}