-
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.
core: fix wildcard type in iterable loop
- Loading branch information
Showing
2 changed files
with
65 additions
and
7 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
47 changes: 47 additions & 0 deletions
47
jadx-core/src/test/java/jadx/tests/integration/generics/TestGenerics6.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,47 @@ | ||
package jadx.tests.integration.generics; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import java.util.Collection; | ||
|
||
import org.junit.Test; | ||
|
||
import static jadx.tests.api.utils.JadxMatchers.containsOne; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class TestGenerics6 extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
public void test1(Collection<? extends A> as) { | ||
for (A a : as) { | ||
a.f(); | ||
} | ||
} | ||
|
||
public void test2(Collection<? extends A> is) { | ||
for (I i : is) { | ||
i.f(); | ||
} | ||
} | ||
|
||
private interface I { | ||
void f(); | ||
} | ||
|
||
private class A implements I { | ||
public void f() { | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("for (A a : as) {")); | ||
// TODO: fix iterable arg type (unexpected cast to A in bytecode) | ||
// assertThat(code, containsOne("for (I i : is) {")); | ||
} | ||
} |