Commit 008216d5 authored by Skylot's avatar Skylot

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

parent 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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment