Skip to content

Commit

Permalink
fix: don't reject type update for generics
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Dec 26, 2018
1 parent 2dea6f5 commit 43de744
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ private boolean checkBound(ArgType candidateType, ITypeBound bound, ArgType boun
return true;

case WIDER:
case WIDER_BY_GENERIC:
return bound.getBound() != BoundEnum.USE;

case NARROW:
Expand All @@ -190,6 +189,7 @@ private boolean checkBound(ArgType candidateType, ITypeBound bound, ArgType boun
}
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {"));
}
}

0 comments on commit 43de744

Please sign in to comment.