Cleanup: apply "cascade if..." inspection (+ some others)

This commit is contained in:
Mikhail Glukhikh
2017-06-28 15:19:20 +03:00
committed by Mikhail Glukhikh
parent 9c06739594
commit 1d2017b0fc
80 changed files with 1079 additions and 1190 deletions
@@ -181,13 +181,10 @@ class SingleInstructionInterpreter(private val eval: Eval) : Interpreter<Value>(
CHECKCAST -> {
val targetType = Type.getObjectType((insn as TypeInsnNode).desc)
if (value == NULL_VALUE) {
NULL_VALUE
} else if (eval.isInstanceOf(value, targetType)) {
ObjectValue(value.obj(), targetType)
}
else {
throwEvalException(ClassCastException("${value.asmType.className} cannot be cast to ${targetType.className}"))
when {
value == NULL_VALUE -> NULL_VALUE
eval.isInstanceOf(value, targetType) -> ObjectValue(value.obj(), targetType)
else -> throwEvalException(ClassCastException("${value.asmType.className} cannot be cast to ${targetType.className}"))
}
}