From 882322a5bf6f9081c81e0e0bd252fead90f27155 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Sat, 17 Nov 2018 14:46:35 +0700 Subject: [PATCH] InferenceSession#isOverloadCheck: take parentheses into account --- .../resolve/graphInference/InferenceSession.java | 2 +- .../castMethodParameters15/afterIncorrectType.java | 14 ++++++++++++++ .../afterIncorrectTypeParens.java | 14 ++++++++++++++ .../beforeIncorrectType.java | 14 ++++++++++++++ .../beforeIncorrectTypeParens.java | 14 ++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectType.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectTypeParens.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectType.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectTypeParens.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index 284bccde652b..7966f0d8ab0c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -387,7 +387,7 @@ public class InferenceSession { if (o instanceof PsiExpressionList) { final PsiExpressionList element = (PsiExpressionList)o; for (PsiExpression expression : element.getExpressions()) { - if (expression == myContext) { + if (PsiUtil.skipParenthesizedExprDown(expression) == myContext) { return true; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectType.java new file mode 100644 index 000000000000..86dfdffa9d2f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectType.java @@ -0,0 +1,14 @@ +// "Cast parameter to 'java.util.Map'" "true" + +import java.util.*; + +class X { + void run(Foo single) {} + void run(Map map) {} + + void test(Bar bar) { + run((Map) Collections.singletonMap(getFoo(), bar)); + } + + native Foo getFoo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectTypeParens.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectTypeParens.java new file mode 100644 index 000000000000..86dfdffa9d2f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/afterIncorrectTypeParens.java @@ -0,0 +1,14 @@ +// "Cast parameter to 'java.util.Map'" "true" + +import java.util.*; + +class X { + void run(Foo single) {} + void run(Map map) {} + + void test(Bar bar) { + run((Map) Collections.singletonMap(getFoo(), bar)); + } + + native Foo getFoo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectType.java new file mode 100644 index 000000000000..fc6f19946380 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectType.java @@ -0,0 +1,14 @@ +// "Cast parameter to 'java.util.Map'" "true" + +import java.util.*; + +class X { + void run(Foo single) {} + void run(Map map) {} + + void test(Bar bar) { + run(Collections.singletonMap(getFoo(), bar)); + } + + native Foo getFoo(); +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectTypeParens.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectTypeParens.java new file mode 100644 index 000000000000..889031d77827 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/castMethodParameters15/beforeIncorrectTypeParens.java @@ -0,0 +1,14 @@ +// "Cast parameter to 'java.util.Map'" "true" + +import java.util.*; + +class X { + void run(Foo single) {} + void run(Map map) {} + + void test(Bar bar) { + run((Collections.singletonMap(getFoo(), bar))); + } + + native Foo getFoo(); +} \ No newline at end of file