[java-highlighting] Refactor FunctionalInterfaceTest to avoid internals dependency; move completion stuff out of LambdaHighlightingUtil

Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 4bd5447dd5fc2342f5e9b23e693f7683594470f5
This commit is contained in:
Tagir Valeev
2025-02-04 19:21:50 +00:00
committed by intellij-monorepo-bot
parent 0eeed91d22
commit fd581aa354
19 changed files with 58 additions and 164 deletions
@@ -1 +1,2 @@
<error descr="Foo is not a functional interface">@FunctionalInterface</error>
abstract class Foo { public abstract void run(); }
@@ -1,3 +1,4 @@
<error descr="Multiple non-overriding abstract methods found in Foo">@FunctionalInterface</error>
interface Foo {
int m();
Object clone();
@@ -8,6 +8,6 @@ interface Y<T> {
class Test {
{
((X & <caret>Y<Integer>) (x) -> {}).m(1);
((X & Y<Integer>) <error descr="Multiple non-overriding abstract methods found in X & Y<Integer>">(x) -> {}</error>).m<error descr="Ambiguous method call: both 'X.m(Integer)' and 'Y.m(Integer)' match">(1)</error>;
}
}
@@ -1,3 +1,8 @@
@FunctionalInterface
interface Foo { <T> T execute(Action<T> a); }
interface Action<A>{}
// Functional
class Use {
// Functional but not lambda-compatible
Foo foo = <error descr="Target method is generic">a -> null</error>;
}
@@ -1,3 +1,4 @@
interface Bar { boolean equals(Object obj); }
@FunctionalInterface
interface Foo extends Bar { int compare(String o1, String o2); }
@@ -1,3 +1,4 @@
@FunctionalInterface
interface Foo<T> {
boolean equals(Object obj);
int compare(T o1, T o2);
@@ -1 +1,2 @@
<error descr="No target method found">@FunctionalInterface</error>
interface Foo { boolean equals(Object obj); }
@@ -1 +1,2 @@
@FunctionalInterface
interface Foo { void run(); }
@@ -1,4 +1,5 @@
interface X { int m(Iterable<String> arg); }
interface Y { int m(Iterable<Integer> arg); }
<error descr="Multiple non-overriding abstract methods found in Foo">@FunctionalInterface</error>
interface Foo extends X, Y {}
// Not functional: No method has a subsignature of all abstract methods
@@ -1,4 +1,5 @@
interface X { int m(Iterable<String> arg, Class c); }
interface Y { int m(Iterable arg, Class<?> c); }
<error descr="Multiple non-overriding abstract methods found in Foo">@FunctionalInterface</error>
interface Foo extends X, Y {}
// Not functional: No method has a subsignature of all abstract methods
@@ -1,4 +1,5 @@
import java.util.*;
interface X { int m(Iterable<String> arg); }
interface Y { int m(Iterable<String> arg); }
@FunctionalInterface
interface Foo extends X, Y {}
@@ -1,5 +1,11 @@
interface Action<A>{}
interface X { <T> T execute(Action<T> a); }
interface Y { <S> S execute(Action<S> a); }
@FunctionalInterface
interface Foo extends X, Y {}
// Functional: signatures are "the same"
class Use {
// Functional: signatures are "the same"
// but not lambda-compatible
Foo foo = <error descr="Target method is generic">a -> null</error>;
}
@@ -2,4 +2,5 @@ interface Foo1<T, N extends Number> {
void m(T arg);
void m(N arg);
}
@FunctionalInterface
interface Foo extends Foo1<Integer, Integer> {}
@@ -1,4 +1,5 @@
import java.util.*;
interface X { Iterable m(Iterable<String> arg); }
interface Y { Iterable<String> m(Iterable arg); }
@FunctionalInterface
interface Foo extends X, Y {}