From 3ee08cbce94a4e7e1ce668f06f5a612cd9f1e677 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 12 Nov 2021 12:58:49 +0100 Subject: Fix mapping of synthetic properties when overridden in Kotlin class In these cases, the getMethod of the property will not have a Psi element and we need to traverse up the overrides until we find one that does. --- .../remap/mapper/kotlin/TestKotlinSyntheticProperties.kt | 13 +++++++++++++ src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt | 2 ++ 2 files changed, 15 insertions(+) (limited to 'src/test/kotlin') 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 b77978a..20b65b9 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 @@ -141,4 +141,17 @@ class TestKotlinSyntheticProperties { val v = B().b """.trimIndent() } + + @Test + fun `remaps synthetic property even when overwritten in kotlin subclass`() { + TestData.remapKt(""" + import pkg.Kt + val v = Kt().syntheticA + fun test() { Kt().syntheticA = Kt() } + """.trimIndent()) shouldBe """ + import pkg.Kt + val v = Kt().syntheticB + fun test() { Kt().syntheticB = Kt() } + """.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 c40635c..c5b8851 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt @@ -40,10 +40,12 @@ object TestData { classpath = arrayOf( findClasspathEntry("org.spongepowered.asm.mixin.Mixin"), findClasspathEntry("a.pkg.A"), + findClasspathEntry("AMarkerKt"), ) remappedClasspath = arrayOf( findClasspathEntry("org.spongepowered.asm.mixin.Mixin"), findClasspathEntry("b.pkg.B"), + findClasspathEntry("BMarkerKt"), ) patternAnnotation = "remap.Pattern" } -- cgit