Skip to content

Commit

Permalink
fix: return type lost after type inference (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
soldierkam authored and skylot committed Nov 23, 2018
1 parent 1fc92d2 commit 3a798cb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ private static ArgType processType(DexNode dex, SSAVar var) {
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);"));
}

}

0 comments on commit 3a798cb

Please sign in to comment.