-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add correct type propagation for check-cast and move instructions (
#401)
- Loading branch information
Showing
2 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver7.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package jadx.tests.integration.types; | ||
|
||
import org.junit.Test; | ||
|
||
import jadx.core.dex.nodes.ClassNode; | ||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.JadxMatchers.containsOne; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class TestTypeResolver7 extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
public void test(boolean a, boolean b) { | ||
Object obj = null; | ||
if (a) { | ||
use(b ? (Exception) getObj() : (Exception) obj); | ||
} else { | ||
Runnable r = (Runnable) obj; | ||
if (b) { | ||
r = (Runnable) getObj(); | ||
} | ||
use(r); | ||
} | ||
} | ||
|
||
private Object getObj() { | ||
return null; | ||
} | ||
|
||
private void use(Exception e) {} | ||
|
||
private void use(Runnable r) {} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
ClassNode cls = getClassNode(TestCls.class); | ||
String code = cls.getCode().toString(); | ||
|
||
assertThat(code, containsOne("use(b ? (Exception) getObj() : null);")); | ||
} | ||
|
||
@Test | ||
public void testNoDebug() { | ||
noDebugInfo(); | ||
getClassNode(TestCls.class); | ||
} | ||
} |