fix: don't inline named variables (#1338)

This commit is contained in:
Skylot
2022-01-28 18:33:38 +00:00
parent 96f90e18e8
commit 84facb13d0
14 changed files with 202 additions and 102 deletions
@@ -537,21 +537,7 @@ public abstract class IntegrationTest extends TestUtils {
}
// Use only for debug purpose
@Deprecated
protected void outputCFG() {
this.args.setCfgOutput(true);
this.args.setRawCFGOutput(true);
}
// Use only for debug purpose
@Deprecated
protected void printDisassemble() {
this.printDisassemble = true;
}
// Use only for debug purpose
@Deprecated
protected void outputRawCFG() {
this.args.setRawCFGOutput(true);
}
}
@@ -0,0 +1,36 @@
package jadx.tests.integration.generics;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
public class TestConstructorGenerics extends IntegrationTest {
@SuppressWarnings({ "MismatchedQueryAndUpdateOfCollection", "RedundantOperationOnEmptyContainer" })
public static class TestCls {
public String test() {
Map<String, String> map = new HashMap<>();
return map.get("test");
}
}
@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("Map<String, String> map = new HashMap<>();");
}
@Test
public void testNoDebug() {
noDebugInfo();
assertThat(getClassNode(TestCls.class))
.code()
.containsOne("return (String) new HashMap().get(\"test\");");
}
}
@@ -19,8 +19,7 @@ public class TestAnonymousClass10 extends IntegrationTest {
public A test() {
Random random = new Random();
int a2 = random.nextInt();
int a3 = a2 + 3;
return new A(this, a2, a3, 4, 5, random.nextDouble()) {
return new A(this, a2, a2 + 3, 4, 5, random.nextDouble()) {
@Override
public void m() {
System.out.println(1);
@@ -32,6 +32,6 @@ public class TestNestedLoops2 extends IntegrationTest {
String code = cls.getCode().toString();
assertThat(code, containsOne("for (int i = 0; i < list.size(); i++) {"));
assertThat(code, containsOne("while (j < list.get(i).length()) {"));
assertThat(code, containsOne("while (j < s.length()) {"));
}
}
@@ -12,6 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestSequentialLoops2 extends IntegrationTest {
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
public static class TestCls {
private static char[] lowercases = new char[] { 'a' };
@@ -14,7 +14,6 @@
fill-array-data v1, :array_0
.local v1, "arr":[J
return v1
:array_0