-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
5 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
jadx-core/src/test/java/jadx/tests/integration/generics/TestImportGenericMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { | ||
} | ||
|
||
} |