mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
poly conditional expression type = target type (IDEA-122401)
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
import java.util.Comparator;
|
||||
|
||||
class NullComparator<T> {
|
||||
private final Comparator<T> real = null;
|
||||
private Comparator<? super T> other;
|
||||
private Comparator<T> another;
|
||||
|
||||
NullComparator(Comparator<? super T> real) {
|
||||
}
|
||||
|
||||
public NullComparator<T> thenComparing() {
|
||||
return new NullComparator<>(real == null ? other : another);
|
||||
}
|
||||
|
||||
Comparator<T> a() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Comparator<? super T> b() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public NullComparator<T> thenComparing1() {
|
||||
return new NullComparator<>(real == null ? a() : b());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,6 +7,6 @@ interface B {}
|
||||
}
|
||||
|
||||
void bar (boolean a, A a1, B b1){
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'T'">T t = a ? a1 : b1;</error>
|
||||
T t = a ? <error descr="Incompatible types. Found: 'A', required: 'T'">a1</error> : <error descr="Incompatible types. Found: 'B', required: 'T'">b1</error>;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class MS {
|
||||
|
||||
void test(boolean cond) {
|
||||
m(cond ? () -> 26 : () -> 24);
|
||||
m<error descr="Ambiguous method call: both 'MS.m(GetInt)' and 'MS.m(GetInteger)' match">(cond ? () -> 26 : () -> new Integer(42))</error>;
|
||||
m<error descr="Cannot resolve method 'm(?)'">(cond ? () -> 26 : () -> new Integer(42))</error>;
|
||||
m(cond ? () -> new Integer(26) : () -> new Integer(42));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Cast to 'B'" "true"
|
||||
class A {
|
||||
void f(B b) {
|
||||
B s = <caret>b == null ? (B) this : b;
|
||||
B s = b == null ? <caret>(B) this : b;
|
||||
}
|
||||
}
|
||||
class B extends A {}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// "Cast to 'B'" "true"
|
||||
class A {
|
||||
void f(B b) {
|
||||
B s = <caret>b == null ? this : b;
|
||||
B s = b == null ? <caret>this : b;
|
||||
}
|
||||
}
|
||||
class B extends A {}
|
||||
Reference in New Issue
Block a user