diff --git a/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java b/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java index 05dc835..ada6abc 100644 --- a/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java +++ b/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java @@ -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); diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index e85cd67..0da0d3b 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -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"); } } diff --git a/testData/classes/ext/Shadow$B.class b/testData/classes/ext/Shadow$B.class new file mode 100644 index 0000000..eeb9d38 Binary files /dev/null and b/testData/classes/ext/Shadow$B.class differ diff --git a/testData/classes/ext/Shadow.class b/testData/classes/ext/Shadow.class new file mode 100644 index 0000000..e576dfd Binary files /dev/null and b/testData/classes/ext/Shadow.class differ diff --git a/testData/classes/pkg/Shadow.class b/testData/classes/pkg/Shadow.class new file mode 100644 index 0000000..61ed27b Binary files /dev/null and b/testData/classes/pkg/Shadow.class differ diff --git a/testData/classes/pkg/TestShadowing.class b/testData/classes/pkg/TestShadowing.class new file mode 100644 index 0000000..228fd8f Binary files /dev/null and b/testData/classes/pkg/TestShadowing.class differ diff --git a/testData/results/TestShadowing.dec b/testData/results/TestShadowing.dec new file mode 100644 index 0000000..45adbea --- /dev/null +++ b/testData/results/TestShadowing.dec @@ -0,0 +1,6 @@ +package pkg; + +class TestShadowing { + ext.Shadow.B instanceOfB = new ext.Shadow.B(); +} + diff --git a/testData/src/ext/Shadow.java b/testData/src/ext/Shadow.java new file mode 100644 index 0000000..02869ca --- /dev/null +++ b/testData/src/ext/Shadow.java @@ -0,0 +1,6 @@ +package ext; + +// companion class for pkg/TestShadowing.java +public class Shadow { + public static class B { } +} \ No newline at end of file diff --git a/testData/src/pkg/Shadow.java b/testData/src/pkg/Shadow.java new file mode 100644 index 0000000..d76fb78 --- /dev/null +++ b/testData/src/pkg/Shadow.java @@ -0,0 +1,4 @@ +package pkg; + +// companion class for pkg/TestShadowing.java +public class Shadow { } \ No newline at end of file diff --git a/testData/src/pkg/TestShadowing.java b/testData/src/pkg/TestShadowing.java new file mode 100644 index 0000000..c8792b2 --- /dev/null +++ b/testData/src/pkg/TestShadowing.java @@ -0,0 +1,5 @@ +package pkg; + +class TestShadowing { + ext.Shadow.B instanceOfB = new ext.Shadow.B(); +} \ No newline at end of file