From 5a1929caccf975352f4703c156fd2cfe9fa2dc56 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 27 Jan 2016 19:58:35 +0300 Subject: [PATCH] overload resolution: cls method text should not be called to avoid decompilation and shortening of the class references --- .../resolve/graphInference/InferenceSession.java | 15 +++++++++++++-- .../clsHighlighting/libs/overload.jar | Bin 0 -> 526 bytes .../codeInsight/clsHighlighting/overload.java | 7 +++++++ .../ClsGenerics18HighlightingTest.java | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/clsHighlighting/libs/overload.jar create mode 100644 java/java-tests/testData/codeInsight/clsHighlighting/overload.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 56c0d8c2c286..6b3819efe7f0 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 @@ -22,6 +22,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.PsiDiamondTypeUtil; +import com.intellij.psi.impl.compiled.ClsMethodImpl; import com.intellij.psi.impl.source.resolve.graphInference.constraints.*; import com.intellij.psi.infos.MethodCandidateInfo; import com.intellij.psi.search.GlobalSearchScope; @@ -608,7 +609,7 @@ public class InferenceSession { for (PsiTypeParameter parameter : typeParameters) { String name = parameter.getName(); if (myContext != null) { - name += Math.abs(myContext.getText().hashCode()); + name += Math.abs(myContext.hashCode()); } InferenceVariable variable = new InferenceVariable(context, parameter, name); result.add(variable); @@ -1500,7 +1501,17 @@ public class InferenceSession { final boolean varargs) { try { //push site substitutor to parameter bounds - m1 = JavaPsiFacade.getElementFactory(m1.getProject()).createMethodFromText(m1.getText(), m1); + final String text; + if (m1 instanceof ClsMethodImpl) { + final StringBuilder builder = new StringBuilder(); + ((ClsMethodImpl)m1).appendMirrorText(0, builder); + text = builder.toString(); + } + else { + text = m1.getText(); + } + + m1 = JavaPsiFacade.getElementFactory(m1.getProject()).createMethodFromText(text, m1); for (PsiTypeParameter parameter : m1.getTypeParameters()) { final PsiClassType[] types = parameter.getExtendsListTypes(); if (types.length > 0) { diff --git a/java/java-tests/testData/codeInsight/clsHighlighting/libs/overload.jar b/java/java-tests/testData/codeInsight/clsHighlighting/libs/overload.jar new file mode 100644 index 0000000000000000000000000000000000000000..f763e86377588d721ba823b3c510870de2522ba3 GIT binary patch literal 526 zcmWIWW@h1HVBlb2h@5Bb!GHvq7+4qz^#7e=Um3}b^mMX7jEtErC)U1qc0Z`>Q1ximklz^VXVGGtY3C*1zPfW{FOToU$rGO=RKYU&SA__Ox~^ zzvr>kXx_IkoKs#VE)8O=;Cg=1<*CE&9N}HJuUAI@i$BT1q<7uDNQ!%_*Gr0n6Yh~GV*LPpg+GOG0IzK?4c}cY8tT~lyjzsPL!?5@B zGN$guGiUF<@$khT(*=C9x1L+Kxo!QA%UgwB