Commit 3a798cb2 authored by Marcin Kamionowski's avatar Marcin Kamionowski Committed by skylot

fix: return type lost after type inference (#396)

parent 1fc92d2a
...@@ -57,11 +57,13 @@ public class TypeInference extends AbstractVisitor { ...@@ -57,11 +57,13 @@ public class TypeInference extends AbstractVisitor {
ArgType type = assign.getType(); ArgType type = assign.getType();
for (RegisterArg arg : useList) { for (RegisterArg arg : useList) {
ArgType useType = arg.getType(); ArgType useType = arg.getType();
if (!type.isTypeKnown() || !useType.isTypeKnown()) {
ArgType newType = ArgType.merge(dex, type, useType); ArgType newType = ArgType.merge(dex, type, useType);
if (newType != null) { if (newType != null) {
type = newType; type = newType;
} }
} }
}
return type; return type;
} }
......
package jadx.tests.integration.arrays;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class TestArrays4 extends SmaliTest {
public static class TestCls {
char[] payload;
public TestCls(byte[] bytes) {
char[] a = toChars(bytes);
this.payload = new char[a.length];
System.arraycopy(a, 0, this.payload, 0, bytes.length);
}
private static char[] toChars(byte[] bArr) {
return new char[bArr.length];
}
}
@Test
public void testArrayTypeInference() {
noDebugInfo();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("char[] toChars = toChars(bArr);"));
}
}
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