提交 008216d5 编写于 作者: S Skylot

fix: don't cast overloaded methods with generics from other class (#448)

上级 4a92275a
......@@ -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('(');
......
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);"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册