diff options
author | Jonas Herzig <me@johni0702.de> | 2019-11-01 02:00:39 +0100 |
---|---|---|
committer | Jonas Herzig <me@johni0702.de> | 2019-11-01 02:00:39 +0100 |
commit | 423c59be1aff5460b6c36bbb8e2cfdcd13de6863 (patch) | |
tree | 2db7a847a6f05c9dcd247a3efaeda9b83a592e32 | |
parent | fcae86692edc4dbb3764174a341cc622099f4969 (diff) | |
download | Remap-423c59be1aff5460b6c36bbb8e2cfdcd13de6863.tar.gz Remap-423c59be1aff5460b6c36bbb8e2cfdcd13de6863.tar.bz2 Remap-423c59be1aff5460b6c36bbb8e2cfdcd13de6863.zip |
Fix crash when synthetic property is re-mapped to non-property
-rw-r--r-- | src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 12 |
1 files 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) + } } } |