ignore most specific check if parameter count were not matched at all clion/144.674
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 28 Oct 2015 14:56:27 +0000 (15:56 +0100)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 28 Oct 2015 15:05:07 +0000 (16:05 +0100)
EA-75076 - AIOOBE: InferenceSession.isMoreSpecific

java/java-analysis-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr/beforeNoParamNumberMatchFound.java [new file with mode: 0644]

index 3ffd0427a74a47339dcdb76c33e89883dbc1728e..f253ac0f3e144bd8697450ba667fa091f38c8e6e 100644 (file)
@@ -111,7 +111,10 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
                 if (argumentList == null) {
                   return null;
                 }
-                conflictResolver.checkParametersNumber(info, argumentList.getExpressions().length, false);
+                final boolean atLeastOneMatchFound = conflictResolver.checkParametersNumber(info, argumentList.getExpressions().length, false);
+                if (!atLeastOneMatchFound) {
+                  return null;
+                }
                 conflictResolver.checkSpecifics(info, MethodCandidateInfo.ApplicabilityLevel.VARARGS, level);
                 if (info.size() > 1) {
                   return null;
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr/beforeNoParamNumberMatchFound.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr/beforeNoParamNumberMatchFound.java
new file mode 100644 (file)
index 0000000..79a7ad5
--- /dev/null
@@ -0,0 +1,21 @@
+// "Replace with expression lambda" "false"
+class IdeaSetterArgsShouldBeFinal {
+
+  interface I {
+    void m1();
+  }
+
+  interface J {
+    void m2();
+  }
+
+  <L> void foo(I i, J j1, J... j){}
+  <K> void foo(I o, I i1, I... i){}
+
+  {
+    foo(() -> {
+      System.ou<caret>t.println("");
+    });
+  }
+
+}
\ No newline at end of file