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/kotlin | |
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/kotlin')
-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 |
2 files changed, 48 insertions, 0 deletions
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" } |