overload resolution: cls method text should not be called to avoid decompilation and shortening of the class references

This commit is contained in:
Anna Kozlova
2016-01-27 20:02:35 +03:00
parent cd98935bbe
commit 5a1929cacc
4 changed files with 22 additions and 2 deletions
@@ -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) {
@@ -0,0 +1,7 @@
import p.A;
class Test {
{
A.assertThat("");
}
}
@@ -29,6 +29,8 @@ public class ClsGenerics18HighlightingTest extends ClsGenericsHighlightingTest {
public void testIDEA127714() { doTest(); }
public void testoverload() { doTest(); }
public void testCaptureContext() {
String name = getTestName(false);
addLibrary(name + ".jar", name + "-sources.jar");