mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda: accept intersection type when exactly one conjunct is functional
This commit is contained in:
@@ -97,18 +97,17 @@ public class LambdaHighlightingUtil {
|
||||
@Nullable
|
||||
public static String checkInterfaceFunctional(PsiType functionalInterfaceType) {
|
||||
if (functionalInterfaceType instanceof PsiIntersectionType) {
|
||||
if (!LambdaUtil.isFunctionalType(functionalInterfaceType)) {
|
||||
int count = 0;
|
||||
for (PsiType type : ((PsiIntersectionType)functionalInterfaceType).getConjuncts()) {
|
||||
if (checkInterfaceFunctional(type) == null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 1) {
|
||||
return "Multiple non-overriding abstract methods found in " + functionalInterfaceType.getPresentableText();
|
||||
int count = 0;
|
||||
for (PsiType type : ((PsiIntersectionType)functionalInterfaceType).getConjuncts()) {
|
||||
if (checkInterfaceFunctional(type) == null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 1) {
|
||||
return "Multiple non-overriding abstract methods found in " + functionalInterfaceType.getPresentableText();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType);
|
||||
final PsiClass aClass = resolveResult.getElement();
|
||||
|
||||
+15
@@ -18,3 +18,18 @@ class Test {
|
||||
Object o5 = (Runnable & A) <error descr="Multiple non-overriding abstract methods found in Runnable & A">() -> {}</error>;
|
||||
}
|
||||
}
|
||||
|
||||
class Test1 {
|
||||
|
||||
interface A {
|
||||
<X> void foo();
|
||||
}
|
||||
|
||||
interface B {
|
||||
void foo();
|
||||
}
|
||||
|
||||
{
|
||||
Object c0 = (A & B) ()->{};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user