lambda -> method ref: do not suggest to replace anonymous classes (IDEA-93588)

This commit is contained in:
anna
2012-10-25 15:08:22 +02:00
parent 75335192ab
commit ce1e18a9c9
2 changed files with 14 additions and 0 deletions

View File

@@ -115,6 +115,7 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT
if (psiMethod == null) {
isConstructor = true;
if (!(methodCall instanceof PsiNewExpression)) return null;
if (((PsiNewExpression)methodCall).getAnonymousClass() != null) return null;
final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)methodCall).getClassOrAnonymousClassReference();
if (classReference == null) return null;
containingClass = (PsiClass)classReference.resolve();

View File

@@ -0,0 +1,13 @@
// "Replace lambda with method reference" "false"
class NonStaticInner3 {
class Foo {
}
interface I1<X> {
X m();
}
{
I1<Foo> b2 = () -> <caret>new Foo(){};
}
}