mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
redundant code block: compare same overload resolution (IDEA-174288)
instead of trying with cast afterwards, don't suggest to remove the block at the first place
This commit is contained in:
@@ -87,7 +87,8 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
|
||||
if (psiExpression != null && !findCommentsOutsideExpression(body, psiExpression)) {
|
||||
if (LambdaUtil.isExpressionStatementExpression(psiExpression)) {
|
||||
final PsiCall call = LambdaUtil.treeWalkUp(body);
|
||||
if (call != null && call.resolveMethod() != null) {
|
||||
PsiMethod oldTarget;
|
||||
if (call != null && (oldTarget = call.resolveMethod()) != null) {
|
||||
final int offsetInTopCall = body.getTextRange().getStartOffset() - call.getTextRange().getStartOffset();
|
||||
PsiCall copyCall = LambdaUtil.copyTopLevelCall(call);
|
||||
if (copyCall == null) return null;
|
||||
@@ -96,7 +97,7 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
|
||||
final PsiElement parent = codeBlock.getParent();
|
||||
if (parent instanceof PsiLambdaExpression) {
|
||||
codeBlock.replace(psiExpression);
|
||||
if (copyCall.resolveMethod() == null || ((PsiLambdaExpression)parent).getFunctionalInterfaceType() == null) {
|
||||
if (copyCall.resolveMethod() != oldTarget || ((PsiLambdaExpression)parent).getFunctionalInterfaceType() == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ class A {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
submit((Runnable) () -> new A());
|
||||
submit(() -> {
|
||||
new A();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user