aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt
index 1000666..a1f6e8b 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt
@@ -36,10 +36,16 @@ internal class PsiPatterns(private val annotationFQN: String) {
candidates.firstOrNull()
} ?: throw RuntimeException("Failed to find updated method \"${method.name}\" (line ${methodLine + 1})")
}
+ val replacementBody = replacementMethod.body!!
- if (method.text == replacementMethod.text) return
+ // If the body does not change, then there is no point in applying this pattern
+ if (body.text == replacementBody.text) return
- val replacementExpression = when (val statement = replacementMethod.body!!.statements.last()) {
+ // If either body is empty, then consider the pattern to be disabled
+ if (body.statements.isEmpty()) return
+ if (replacementBody.statements.isEmpty()) return
+
+ val replacementExpression = when (val statement = replacementBody.statements.last()) {
is PsiReturnStatement -> statement.returnValue!!
else -> statement
}