fix: return type lost after type inference (#396)
This commit is contained in:
committed by
skylot
parent
1fc92d2a16
commit
3a798cb21c
@@ -56,11 +56,13 @@ public class TypeInference extends AbstractVisitor {
|
||||
}
|
||||
ArgType type = assign.getType();
|
||||
for (RegisterArg arg : useList) {
|
||||
ArgType useType = arg.getType();
|
||||
ArgType newType = ArgType.merge(dex, type, useType);
|
||||
if (newType != null) {
|
||||
type = newType;
|
||||
}
|
||||
ArgType useType = arg.getType();
|
||||
if (!type.isTypeKnown() || !useType.isTypeKnown()) {
|
||||
ArgType newType = ArgType.merge(dex, type, useType);
|
||||
if (newType != null) {
|
||||
type = newType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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);"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user