Skip to content

Commit

Permalink
Add some failing tests for potential issues I noticed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jan 5, 2024
1 parent a1fbbbc commit a6ec3fb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,21 @@ class TestMixinInjections {
}
""".trimIndent()
}

@Test
fun `remaps synthetic bridges that change the return type inside inner classes inside inner classes`() {
TestData.remap("""
@org.spongepowered.asm.mixin.Mixin(a.pkg.A.InnerB.InnerC.class)
class MixinA {
@org.spongepowered.asm.mixin.injection.Inject(method = "getA()La/pkg/A${'$'}InnerB${'$'}InnerC")
private void test() {}
}
""".trimIndent()) shouldBe """
@org.spongepowered.asm.mixin.Mixin(b.pkg.B.InnerB.InnerC.class)
class MixinA {
@org.spongepowered.asm.mixin.injection.Inject(method = "getB()Lb/pkg/B${'$'}InnerB${'$'}InnerC")
private void test() {}
}
""".trimIndent()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,23 @@ class TestMiscJavaCode {
}
""".trimIndent()
}

@Test
fun `remaps methods that are called on the return value of another method when using synthetic bridges that change the return type`() {
TestData.remap("""
public class Test {
public static void test() {
final a.pkg.A value = null;
value.aGeneratedSynthetic().aGeneratedSynthetic().aGeneratedSynthetic();
}
}
""".trimIndent()) shouldBe """
public class Test {
public static void test() {
final b.pkg.B value = null;
value.bGeneratedSynthetic().bGeneratedSynthetic().bGeneratedSynthetic();
}
}
""".trimIndent()
}
}
13 changes: 13 additions & 0 deletions src/testA/java/a/pkg/A.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,17 @@ public class InnerA {
}

public class GenericA<T> {}

public static class InnerC {
public InnerC getA() {
return this;
}

public static class InnerD extends InnerC {
@Override
public InnerD getA() {
return this;
}
}
}
}
13 changes: 13 additions & 0 deletions src/testB/java/b/pkg/B.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,17 @@ public class InnerB {
}

public class GenericB<T> {}

public static class InnerC {
public InnerC getB() {
return this;
}

public static class InnerD extends InnerC {
@Override
public InnerD getB() {
return this;
}
}
}
}

0 comments on commit a6ec3fb

Please sign in to comment.