aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod/gradle
diff options
context:
space:
mode:
authorJonas Herzig <jonas@spark-squared.com>2021-11-12 12:58:49 +0100
committerJonas Herzig <jonas@spark-squared.com>2021-11-13 10:28:09 +0100
commit3ee08cbce94a4e7e1ce668f06f5a612cd9f1e677 (patch)
tree940042d08d31be55f9c1ea643bf3cf41070121ce /src/main/kotlin/com/replaymod/gradle
parentb30404f156adb6e01bfe4edc50b4de4245ba4509 (diff)
downloadRemap-3ee08cbce94a4e7e1ce668f06f5a612cd9f1e677.tar.gz
Remap-3ee08cbce94a4e7e1ce668f06f5a612cd9f1e677.tar.bz2
Remap-3ee08cbce94a4e7e1ce668f06f5a612cd9f1e677.zip
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.
Diffstat (limited to 'src/main/kotlin/com/replaymod/gradle')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index 13bcc14..0ad498b 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
+import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeAsSequence
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor.Companion.propertyNameByGetMethodName
import java.util.*
@@ -150,7 +151,10 @@ internal class PsiMapper(
}
private fun map(expr: PsiElement, property: SyntheticJavaPropertyDescriptor) {
- val getter = property.getMethod.findPsi() as? PsiMethod ?: return
+ val getter = property.getMethod
+ .overriddenTreeAsSequence(false)
+ .firstNotNullOfOrNull { it.findPsi() }
+ as? PsiMethod ?: return
val mapping = findMapping(getter)
val mappedGetter = mapping?.deobfuscatedName ?: return
if (mappedGetter != getter.name) {