diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java b/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java index 7fc82bb99..e843b1feb 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java @@ -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 diff --git a/jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics.java b/jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics.java new file mode 100644 index 000000000..88bb51032 --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/types/TestGenerics.java @@ -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 { + private T data; + + public TestCls 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 data(T t) {")); + } + + @Test + public void test2() { +// setFallback(); + noDebugInfo(); + ClassNode cls = getClassNode(TestCls.class); + String code = cls.getCode().toString(); + + assertThat(code, containsOne("TestCls data(T t) {")); + } +}