Decompiler name shadowing resolution

https://github.com/JetBrains/intellij-community/pull/295
This commit is contained in:
Alexandru-Constantin Bledea
2015-09-07 20:44:51 +03:00
committed by Roman Shevchenko
parent ee740aa056
commit 766fc1390d
10 changed files with 24 additions and 1 deletions

View File

@@ -99,7 +99,8 @@ public class ImportCollector {
if (existsDefaultClass ||
(mapSimpleNames.containsKey(nshort) && !npackage.equals(mapSimpleNames.get(nshort)))) {
return fullname;
// don't return full name because if the class is a inner class, full name refers to the parent full name, not the child full name
return retname == null ? fullname : (npackage + "." + retname);
}
else if (!mapSimpleNames.containsKey(nshort)) {
mapSimpleNames.put(nshort, npackage);

View File

@@ -61,4 +61,5 @@ public class SingleClassesTest extends SingleClassesTestBase {
@Test public void testInnerLocalPkg() { doTest("pkg/TestInnerLocalPkg"); }
@Test public void testInnerSignature() { doTest("pkg/TestInnerSignature"); }
@Test public void testParameterizedTypes() { doTest("pkg/TestParameterizedTypes"); }
@Test public void testShadowing() { doTest("pkg/TestShadowing", "pkg/Shadow", "ext/Shadow"); }
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
package pkg;
class TestShadowing {
ext.Shadow.B instanceOfB = new ext.Shadow.B();
}

View File

@@ -0,0 +1,6 @@
package ext;
// companion class for pkg/TestShadowing.java
public class Shadow {
public static class B { }
}

View File

@@ -0,0 +1,4 @@
package pkg;
// companion class for pkg/TestShadowing.java
public class Shadow { }

View File

@@ -0,0 +1,5 @@
package pkg;
class TestShadowing {
ext.Shadow.B instanceOfB = new ext.Shadow.B();
}