mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
don't open captures on type computation (IDEA-154968)
This commit is contained in:
+1
-1
@@ -30,6 +30,6 @@ class Foo<T> {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Foo<?> foo = getFoo();
|
||||
double value = (double) foo.getValue();
|
||||
double value = <error descr="Inconvertible types; cannot cast 'capture<?>' to 'double'">(double) foo.getValue()</error>;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@ abstract class A<T, S extends T>
|
||||
{
|
||||
abstract S bar();
|
||||
void foo(A<Runnable[], ? extends Cloneable[]> a){
|
||||
<error descr="Incompatible types. Found: 'java.lang.Cloneable[]', required: 'java.lang.Runnable[]'">Runnable[] x = a.bar();</error>
|
||||
<error descr="Incompatible types. Found: 'capture<? extends java.lang.Cloneable[]>', required: 'java.lang.Runnable[]'">Runnable[] x = a.bar();</error>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ abstract class AC<T, S>
|
||||
{
|
||||
abstract S bar();
|
||||
void foo(AC<Runnable[], ? extends Cloneable[]> a){
|
||||
<error descr="Incompatible types. Found: 'java.lang.Cloneable[]', required: 'java.lang.Runnable[]'">Runnable[] x = a.bar();</error>
|
||||
<error descr="Incompatible types. Found: 'capture<? extends java.lang.Cloneable[]>', required: 'java.lang.Runnable[]'">Runnable[] x = a.bar();</error>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ class VarianceTesting {
|
||||
VarianceTesting t = l1.get(0);
|
||||
l.add(new VarianceTesting());
|
||||
l.add(null);
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'VarianceTesting'">VarianceTesting t1 = l.get(0);</error>
|
||||
<error descr="Incompatible types. Found: 'capture<? super VarianceTesting>', required: 'VarianceTesting'">VarianceTesting t1 = l.get(0);</error>
|
||||
X<? extends VarianceTesting> x1 = null;
|
||||
x1.putAll(new ArrayList<VarianceTesting>());
|
||||
List<?> unknownlist = l;
|
||||
@@ -142,7 +142,7 @@ class S1 {
|
||||
}
|
||||
|
||||
void bar(List<? extends S1> k) {
|
||||
f(k, <error descr="'f(java.util.List<capture<? extends S1>>, capture<? extends S1>)' in 'S1' cannot be applied to '(java.util.List<capture<? extends S1>>, S1)'">k.get(0)</error>);
|
||||
f(k, <error descr="'f(java.util.List<capture<? extends S1>>, capture<? extends S1>)' in 'S1' cannot be applied to '(java.util.List<capture<? extends S1>>, capture<? extends S1>)'">k.get(0)</error>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
class Test {
|
||||
<E, K> HashMap<K, ArrayList<E>> foo(ArrayList<E> list, BiFunction<E, Comparable<E>, K> getKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bar(ArrayList<? extends Number> list) {
|
||||
HashMap<Integer, ? extends ArrayList<? extends Number>> foo = foo(list, (x, c) -> c.compareTo(x));
|
||||
}
|
||||
|
||||
Set<Integer> baz(ArrayList<? extends Number> list) {
|
||||
return foo(list, (x, c) -> c.compareTo(x)).keySet(); // False error in lambda: 'compareTo(capture<? extends java.lang.Number>)' in 'java.lang.Comparable' cannot be applied to '(java.lang.Number)'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user