fix: respect arg offset for type var mapping on invoke (PR #2698)
fix: respect arg offset for type var apping on invoke
This commit is contained in:
@@ -242,9 +242,9 @@ public class TypeUtils {
|
||||
}
|
||||
Map<ArgType, ArgType> map = new HashMap<>(1 + invokeInsn.getArgsCount());
|
||||
addTypeVarMapping(map, mthDetails.getReturnType(), invokeInsn.getResult());
|
||||
int argCount = Math.min(mthDetails.getArgTypes().size(), invokeInsn.getArgsCount());
|
||||
int argCount = Math.min(mthDetails.getArgTypes().size(), invokeInsn.getArgsCount() - invokeInsn.getFirstArgOffset());
|
||||
for (int i = 0; i < argCount; i++) {
|
||||
addTypeVarMapping(map, mthDetails.getArgTypes().get(i), invokeInsn.getArg(i));
|
||||
addTypeVarMapping(map, mthDetails.getArgTypes().get(i), invokeInsn.getArg(i + invokeInsn.getFirstArgOffset()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package jadx.tests.integration.invoke;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
import jadx.tests.api.utils.assertj.JadxAssertions;
|
||||
|
||||
public class TestOverloadedMethodInvoke2 extends IntegrationTest {
|
||||
|
||||
public static class AbstractItem {
|
||||
|
||||
public void doSomething(Container c, Item i) {
|
||||
c.add(i);
|
||||
}
|
||||
|
||||
public static class Container {
|
||||
|
||||
public <T extends AbstractItem> int add(T t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void add(AbstractItem... item) {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Item extends AbstractItem {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
JadxAssertions.assertThat(getClassNode(TestOverloadedMethodInvoke2.AbstractItem.class))
|
||||
.code().containsOne("c.add(i);")
|
||||
.doesNotContain("(Container)");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user