From 423c59be1aff5460b6c36bbb8e2cfdcd13de6863 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 1 Nov 2019 02:00:39 +0100 Subject: Fix crash when synthetic property is re-mapped to non-property --- src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt index 44efec6..7d4c054 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt @@ -113,8 +113,16 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile) val getter = property.getMethod.findPsi() as? PsiMethod ?: return val mappedGetter = findMapping(getter) ?: return if (mappedGetter != getter.name) { - val mapped = propertyNameByGetMethodName(Name.identifier(mappedGetter))!!.identifier - replaceIdentifier(expr, mapped) + val maybeMapped = propertyNameByGetMethodName(Name.identifier(mappedGetter)) + if (maybeMapped == null) { + // Can happen if a method is a synthetic property in the current mapping (e.g. `isNonBoss`) but not + // in the target mapping (e.g. `canUsePortal()`) + // TODO probably also want to convert in the opposite direction, though that's a lot harder + replaceIdentifier(expr, "$mappedGetter()") + } else { + val mapped = maybeMapped.identifier + replaceIdentifier(expr, mapped) + } } } -- cgit