fix: don't reject type update for generics
This commit is contained in:
@@ -181,7 +181,6 @@ public final class TypeUpdate {
|
||||
return true;
|
||||
|
||||
case WIDER:
|
||||
case WIDER_BY_GENERIC:
|
||||
return bound.getBound() != BoundEnum.USE;
|
||||
|
||||
case NARROW:
|
||||
@@ -190,6 +189,7 @@ public final class TypeUpdate {
|
||||
}
|
||||
return true;
|
||||
|
||||
case WIDER_BY_GENERIC:
|
||||
case NARROW_BY_GENERIC:
|
||||
// allow replace object to same object with known generic type
|
||||
// due to incomplete information about external methods and fields
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package jadx.tests.integration.types;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
|
||||
import static jadx.tests.api.utils.JadxMatchers.containsOne;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class TestGenerics extends IntegrationTest {
|
||||
|
||||
public static class TestCls<T> {
|
||||
private T data;
|
||||
|
||||
public TestCls<T> data(T t) {
|
||||
this.data = t;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, containsOne("TestCls<T> data(T t) {"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
// setFallback();
|
||||
noDebugInfo();
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, containsOne("TestCls<T> data(T t) {"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user