fix: don't cast overloaded methods with generics from other class (#448)
This commit is contained in:
@@ -733,6 +733,10 @@ public class InsnGen {
|
||||
origType = callMth.getMethodInfo().getArgumentsTypes().get(origPos);
|
||||
} else {
|
||||
origType = arguments.get(origPos).getInitType();
|
||||
if (origType.isGenericType() && !callMth.getParentClass().equals(mth.getParentClass())) {
|
||||
// cancel cast
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!arg.getType().equals(origType)) {
|
||||
code.add('(');
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package jadx.tests.integration.invoke;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
|
||||
import static jadx.tests.api.utils.JadxMatchers.containsOne;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
|
||||
public class TestSuperInvokeWithGenerics extends IntegrationTest {
|
||||
|
||||
public static class TestCls {
|
||||
|
||||
public class A<T extends Exception, V> {
|
||||
public A(T t) {
|
||||
System.out.println("t" + t);
|
||||
}
|
||||
|
||||
public A(V v) {
|
||||
System.out.println("v" + v);
|
||||
}
|
||||
}
|
||||
|
||||
public class B extends A<Exception, String> {
|
||||
public B(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public B(Exception e) {
|
||||
super(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, containsOne("super(e);"));
|
||||
assertThat(code, containsOne("super(s);"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user