diff --git a/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver8.java b/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver8.java new file mode 100644 index 000000000..021eca216 --- /dev/null +++ b/jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver8.java @@ -0,0 +1,47 @@ +package jadx.tests.integration.types; + +import org.junit.jupiter.api.Test; + +import jadx.NotYetImplemented; +import jadx.core.dex.nodes.ClassNode; +import jadx.tests.api.SmaliTest; + +import static jadx.tests.api.utils.JadxMatchers.containsOne; +import static org.hamcrest.MatcherAssert.assertThat; + +public class TestTypeResolver8 extends SmaliTest { + + // @formatter:off + /* + public class A {} + + public class B { + public B(A a) { + } + } + + public static class TestCls { + private A f; + + public void test() { + A x = this.f; + if (x != null) { + x = new B(x); // different types, type of 'x' can't be resolved + } + use(x); + } + + private void use(B b) {} + } + */ + // @formatter:on + + @Test + @NotYetImplemented + public void test() { + ClassNode cls = getClassNodeFromSmaliFiles("types", "TestTypeResolver8", "TestCls"); + String code = cls.getCode().toString(); + + assertThat(code, containsOne("use(a != null ? new B(a) : null);")); + } +} diff --git a/jadx-core/src/test/smali/types/TestTypeResolver8/A.smali b/jadx-core/src/test/smali/types/TestTypeResolver8/A.smali new file mode 100644 index 000000000..bace4f1a8 --- /dev/null +++ b/jadx-core/src/test/smali/types/TestTypeResolver8/A.smali @@ -0,0 +1,23 @@ +.class public Ltypes/TestCls$A; +.super Ljava/lang/Object; + + +# annotations +.annotation system Ldalvik/annotation/EnclosingClass; + value = Ljadx/tests/integration/types/TestTypeResolver8$TestCls; +.end annotation + +.annotation system Ldalvik/annotation/InnerClass; + accessFlags = 0x9 + name = "A" +.end annotation + + +# direct methods +.method public constructor ()V + .registers 1 + + invoke-direct {p0}, Ljava/lang/Object;->()V + + return-void +.end method diff --git a/jadx-core/src/test/smali/types/TestTypeResolver8/B.smali b/jadx-core/src/test/smali/types/TestTypeResolver8/B.smali new file mode 100644 index 000000000..981d14320 --- /dev/null +++ b/jadx-core/src/test/smali/types/TestTypeResolver8/B.smali @@ -0,0 +1,23 @@ +.class public Ltypes/TestCls$B; +.super Ljava/lang/Object; + + +# annotations +.annotation system Ldalvik/annotation/EnclosingClass; + value = Ltypes/TestCls; +.end annotation + +.annotation system Ldalvik/annotation/InnerClass; + accessFlags = 0x9 + name = "B" +.end annotation + + +# direct methods +.method public constructor (Ltypes/A;)V + .registers 2 + + invoke-direct {p0}, Ljava/lang/Object;->()V + + return-void +.end method diff --git a/jadx-core/src/test/smali/types/TestTypeResolver8/TestCls.smali b/jadx-core/src/test/smali/types/TestTypeResolver8/TestCls.smali new file mode 100644 index 000000000..68d5ecfe8 --- /dev/null +++ b/jadx-core/src/test/smali/types/TestTypeResolver8/TestCls.smali @@ -0,0 +1,61 @@ +.class public Ltypes/TestCls; +.super Ljava/lang/Object; + + +# annotations +.annotation system Ldalvik/annotation/EnclosingClass; + value = Ljadx/tests/integration/types/TestTypeResolver8; +.end annotation + +.annotation system Ldalvik/annotation/InnerClass; + accessFlags = 0x9 + name = "TestCls" +.end annotation + +.annotation system Ldalvik/annotation/MemberClasses; + value = { + Ltypes/TestCls$B;, + Ltypes/TestCls$A; + } +.end annotation + + +# instance fields +.field private f:Ltypes/TestCls$A; + + +# direct methods +.method public constructor ()V + .registers 1 + + invoke-direct {p0}, Ljava/lang/Object;->()V + + return-void +.end method + +.method private use(Ltypes/TestCls$B;)V + .registers 2 + + return-void +.end method + + +# virtual methods +.method public test()V + .registers 3 + + iget-object v1, p0, Ltypes/TestCls;->f:Ltypes/TestCls$A; + + if-eqz v1, :cond_a + + new-instance v0, Ltypes/TestCls$B; + + invoke-direct {v0, v1}, Ltypes/TestCls$B;->(Ltypes/TestCls$A;)V + + move v1, v0 + + :cond_a + invoke-direct {p0, v1}, Ltypes/TestCls;->use(Ltypes/TestCls$B;)V + + return-void +.end method