Commit 56c0a588 authored by Skylot's avatar Skylot

core: fix imports for inner classes with same names

parent 47d65fcd
......@@ -397,10 +397,15 @@ public class ClassGen {
if (classInfo.getPackage().equals(useCls.getPackage())) {
fullName = classInfo.getNameWithoutPackage();
}
for (ClassInfo importCls : imports) {
for (ClassInfo importCls : getImports()) {
if (!importCls.equals(classInfo)
&& importCls.getShortName().equals(shortName)) {
return fullName;
if (classInfo.isInner()) {
String parent = useClassInternal(useCls, classInfo.getParentClass());
return parent + "." + shortName;
} else {
return fullName;
}
}
}
addImport(classInfo);
......@@ -416,6 +421,14 @@ public class ClassGen {
}
}
private Set<ClassInfo> getImports() {
if (parentGen != null) {
return parentGen.getImports();
} else {
return imports;
}
}
private static boolean isClassInnerFor(ClassInfo inner, ClassInfo parent) {
if (inner.isInner()) {
ClassInfo p = inner.getParentClass();
......@@ -449,10 +462,6 @@ public class ClassGen {
}
}
public Set<ClassInfo> getImports() {
return imports;
}
public ClassGen getParentGen() {
return parentGen;
}
......
package jadx.samples;
import jadx.samples.otherpkg.C.E;
import jadx.samples.otherpkg.D;
public class TestImports2 extends AbstractTest {
public Object f1() {
return new E() {
@Override
public String toString() {
return "C.E";
}
};
}
public Object f2() {
return new D.E() {
@Override
public String toString() {
return "D.E";
}
};
}
public static class X1 extends E {
}
public static class X2 extends D.E {
}
@Override
public boolean testRun() {
return true;
}
public static void main(String[] args) {
new TestImports2().testRun();
}
}
package jadx.samples.otherpkg;
public class C {
public static class E {
}
}
package jadx.samples.otherpkg;
public class D {
public static class E {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment