diff options
author | Jonas Herzig <jonas@spark-squared.com> | 2021-11-12 10:58:10 +0100 |
---|---|---|
committer | Jonas Herzig <jonas@spark-squared.com> | 2021-11-12 15:23:25 +0100 |
commit | 5723e6481d2f4e07b6820201e74924643b5687bc (patch) | |
tree | 8e91c4b8a1e2e59cac1fad71209670309b2f5153 /src/test | |
parent | 0e7f8ea1d9ebd42bcd88506e771a8b5a1e9ba0b9 (diff) | |
download | Remap-5723e6481d2f4e07b6820201e74924643b5687bc.tar.gz Remap-5723e6481d2f4e07b6820201e74924643b5687bc.tar.bz2 Remap-5723e6481d2f4e07b6820201e74924643b5687bc.zip |
Fix synthetic property becoming shadowed by field of same name
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/a/pkg/A.java | 5 | ||||
-rw-r--r-- | src/test/java/b/pkg/B.java | 5 | ||||
-rw-r--r-- | src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt | 44 | ||||
-rw-r--r-- | src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt | 4 | ||||
-rw-r--r-- | src/test/resources/mappings.srg | 2 |
5 files changed, 60 insertions, 0 deletions
diff --git a/src/test/java/a/pkg/A.java b/src/test/java/a/pkg/A.java index fd177e5..f4a30ef 100644 --- a/src/test/java/a/pkg/A.java +++ b/src/test/java/a/pkg/A.java @@ -62,6 +62,11 @@ public class A extends AParent implements AInterface { public void setterBooleanA(boolean arg) { } + public int conflictingField; + public int getConflictingFieldWithoutConflict() { + return conflictingField; + } + public void aOverloaded() { } diff --git a/src/test/java/b/pkg/B.java b/src/test/java/b/pkg/B.java index b153be4..150ab0b 100644 --- a/src/test/java/b/pkg/B.java +++ b/src/test/java/b/pkg/B.java @@ -62,6 +62,11 @@ public class B extends BParent implements BInterface { public void setterBooleanB(boolean arg) { } + public int conflictingField; + public int getConflictingField() { + return conflictingField; + } + public void bOverloaded() { } diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt index d0f6fc2..b77978a 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt @@ -97,4 +97,48 @@ class TestKotlinSyntheticProperties { } """.trimIndent() } + + @Test + fun `does not convert getter to synthetic property if it would be shadowed by a field with the same name`() { + TestData.remapKt(""" + import a.pkg.A + val v = A().getConflictingFieldWithoutConflict() + """.trimIndent()) shouldBe """ + import b.pkg.B + val v = B().getConflictingField() + """.trimIndent() + } + + @Test + fun `does convert getter to synthetic property if the field which it would be shadowed by is inaccessible`() { + TestData.remapKt(""" + import a.pkg.A + val v = A().getA() + """.trimIndent()) shouldBe """ + import b.pkg.B + val v = B().b + """.trimIndent() + } + + @Test + fun `convert synthetic property to getter if it would be shadowed by a field with the same name`() { + TestData.remapKt(""" + import a.pkg.A + val v = A().conflictingFieldWithoutConflict + """.trimIndent()) shouldBe """ + import b.pkg.B + val v = B().getConflictingField() + """.trimIndent() + } + + @Test + fun `does not convert synthetic property to getter if the field which it would be shadowed by is inaccessible`() { + TestData.remapKt(""" + import a.pkg.A + val v = A().a + """.trimIndent()) shouldBe """ + import b.pkg.B + val v = B().b + """.trimIndent() + } } diff --git a/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt b/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt index adb6f52..c40635c 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt @@ -41,6 +41,10 @@ object TestData { findClasspathEntry("org.spongepowered.asm.mixin.Mixin"), findClasspathEntry("a.pkg.A"), ) + remappedClasspath = arrayOf( + findClasspathEntry("org.spongepowered.asm.mixin.Mixin"), + findClasspathEntry("b.pkg.B"), + ) patternAnnotation = "remap.Pattern" } diff --git a/src/test/resources/mappings.srg b/src/test/resources/mappings.srg index df3d7ef..f8255aa 100644 --- a/src/test/resources/mappings.srg +++ b/src/test/resources/mappings.srg @@ -15,6 +15,8 @@ MD: a/pkg/A/getterA ()La/pkg/A; b/pkg/B/getNonSyntheticB ()Lb/pkg/B; MD: a/pkg/A/setterA (La/pkg/A;)V; b/pkg/B/setNonSyntheticB (Lb/pkg/B;)V; MD: a/pkg/A/getterBooleanA ()Z; b/pkg/B/isNonSyntheticBooleanB ()Z; MD: a/pkg/A/setterBooleanA (Z)V; b/pkg/B/setNonSyntheticBooleanB (Z)V; +FD: a/pkg/A/conflictingField b/pkg/B/conflictingField +MD: a/pkg/A/getConflictingFieldWithoutConflict ()I; b/pkg/B/getConflictingField ()I; MD: a/pkg/A/aOverloaded ()V b/pkg/B/bOverloaded ()V MD: a/pkg/A/aOverloaded (I)V b/pkg/B/bOverloaded (I)V MD: a/pkg/A/aOverloaded (Z)V b/pkg/B/bOverloaded (Z)V |