fix: add missing import for class generics map (PR #480)

* Fix missing import for class Generics map.
* Add import only when needed (in non-inner class declaration)
* Remove unneeded import
This commit is contained in:
Ahmed Ashour
2019-03-21 15:11:56 +01:00
committed by skylot
parent 9797fe5b81
commit dd2e7e879b
5 changed files with 49 additions and 5 deletions
@@ -0,0 +1,40 @@
package jadx.tests.integration.generics;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
public class TestImportGenericMap extends IntegrationTest {
@Test
public void test() {
ClassNode cls = getClassNode(SuperClass.class);
String code = cls.getCode().toString();
assertThat(code, containsString(
"import " + SuperClass.ToImport.class.getName().replace('$', '.') + ';'));
assertThat(code, not(containsString(
"import " + SuperClass.NotToImport.class.getName().replace('$', '.') + ';')));
}
}
final class SuperClass<O extends SuperClass.ToImport> {
interface ToImport {
}
interface NotToImport {
}
static final class Class1<C extends NotToImport> {
}
public <C extends NotToImport> SuperClass(Class1<C> zzf) {
}
}