mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
anonymous -> lambda: do not collapse to lambda functional interfaces with generics methods, accepted by method refs though
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspection
|
||||
super.visitAnonymousClass(aClass);
|
||||
if (PsiUtil.getLanguageLevel(aClass).isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
final PsiClassType baseClassType = aClass.getBaseClassType();
|
||||
if (LambdaUtil.isFunctionalType(baseClassType)) {
|
||||
if (LambdaHighlightingUtil.checkInterfaceFunctional(baseClassType) == null) {
|
||||
final PsiElement lambdaContext = aClass.getParent().getParent();
|
||||
if (LambdaUtil.isValidLambdaContext(lambdaContext) || !(lambdaContext instanceof PsiExpressionStatement)) {
|
||||
final PsiMethod[] methods = aClass.getMethods();
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with lambda" "false"
|
||||
class Test {
|
||||
interface A {
|
||||
<K> void foo();
|
||||
}
|
||||
{
|
||||
A a = new <caret>A() {
|
||||
@Override
|
||||
public <K> void foo() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with method reference" "true"
|
||||
class Main {
|
||||
|
||||
interface A {
|
||||
<K> void foo();
|
||||
}
|
||||
|
||||
static void mm(){}
|
||||
|
||||
{
|
||||
A a = Main::mm;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with method reference" "true"
|
||||
class Main {
|
||||
|
||||
interface A {
|
||||
<K> void foo();
|
||||
}
|
||||
|
||||
static void mm(){}
|
||||
|
||||
{
|
||||
A a = new A<caret>() {
|
||||
@Override
|
||||
public <K> void foo() {
|
||||
mm();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user