Commit baea5247 authored by Skylot's avatar Skylot

test: type inference issue (#462)

parent 0ca2789a
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);"));
}
}
.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 <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.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 <init>(Ltypes/A;)V
.registers 2
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.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 <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()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;-><init>(Ltypes/TestCls$A;)V
move v1, v0
:cond_a
invoke-direct {p0, v1}, Ltypes/TestCls;->use(Ltypes/TestCls$B;)V
return-void
.end method
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment