Commit 77cee15d authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

fix: add cast for null in overloaded methods (#636) (PR #637)

parent e7e7b664
......@@ -762,7 +762,10 @@ public class InsnGen {
}
}
ArgType argType = arg.getType();
if (argType.equals(origType)) {
if (argType.equals(origType)
// null cast to object
&& (!arg.isLiteral() || ((LiteralArg) arg).getLiteral() != 0
|| (!argType.isArray() && !argType.isObject()))) {
return false;
}
if (origType.isGeneric()) {
......
package jadx.tests.integration.others;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
public class TestCastOfNull extends IntegrationTest {
public static class TestCls {
public void test() {
m((long[]) null);
m((String) null);
}
public void m(long[] a) {
}
public void m(String s) {
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("m((long[]) null);"));
assertThat(code, containsOne("m((String) null);"));
}
}
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