From f38253f2fcf63a3b4b5ad7142a6b07e414c9559f Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 21 Nov 2021 12:58:01 +0000 Subject: [PATCH] Add else branch to non-exhaustive when statements Signed-off-by: Graham --- .../org/openrs2/deob/ast/transform/IdentityTransformer.kt | 1 + .../openrs2/deob/ast/transform/NegativeLiteralTransformer.kt | 1 + deob-ast/src/main/kotlin/org/openrs2/deob/ast/util/ExprUtils.kt | 1 + .../openrs2/deob/bytecode/transform/ConstantArgTransformer.kt | 2 ++ .../main/kotlin/org/openrs2/game/net/js5/Js5ChannelHandler.kt | 1 + 5 files changed, 6 insertions(+) diff --git a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/IdentityTransformer.kt b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/IdentityTransformer.kt index a783cac8..ceb687b4 100644 --- a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/IdentityTransformer.kt +++ b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/IdentityTransformer.kt @@ -52,6 +52,7 @@ public class IdentityTransformer : Transformer() { expr.replace(expr.left) } } + else -> Unit } } diff --git a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt index f3e1030d..98ba048d 100644 --- a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt +++ b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt @@ -22,6 +22,7 @@ public class NegativeLiteralTransformer : Transformer() { when (expr.operator) { UnaryExpr.Operator.PLUS -> expr.replace(operand) UnaryExpr.Operator.MINUS -> expr.replace(operand.negate()) + else -> Unit } } } diff --git a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/util/ExprUtils.kt b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/util/ExprUtils.kt index e18dc649..541ce0db 100644 --- a/deob-ast/src/main/kotlin/org/openrs2/deob/ast/util/ExprUtils.kt +++ b/deob-ast/src/main/kotlin/org/openrs2/deob/ast/util/ExprUtils.kt @@ -91,6 +91,7 @@ public fun Expression.not(): Expression { return BinaryExpr(left.not(), right.not(), BinaryExpr.Operator.OR) BinaryExpr.Operator.OR -> return BinaryExpr(left.not(), right.not(), BinaryExpr.Operator.AND) + else -> Unit } } is BooleanLiteralExpr -> return BooleanLiteralExpr(!value) diff --git a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt index 65303421..110bd090 100644 --- a/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt +++ b/deob-bytecode/src/main/kotlin/org/openrs2/deob/bytecode/transform/ConstantArgTransformer.kt @@ -210,6 +210,7 @@ public class ConstantArgTransformer @Inject constructor(private val profile: Pro when (IntBranch.evaluateUnary(insn.opcode, value.set.values)) { ALWAYS_TAKEN -> alwaysTakenBranches += insn NEVER_TAKEN -> neverTakenBranches += insn + else -> Unit } } IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE -> { @@ -223,6 +224,7 @@ public class ConstantArgTransformer @Inject constructor(private val profile: Pro when (IntBranch.evaluateBinary(insn.opcode, value1.set.values, value2.set.values)) { ALWAYS_TAKEN -> alwaysTakenBranches += insn NEVER_TAKEN -> neverTakenBranches += insn + else -> Unit } } } diff --git a/game/src/main/kotlin/org/openrs2/game/net/js5/Js5ChannelHandler.kt b/game/src/main/kotlin/org/openrs2/game/net/js5/Js5ChannelHandler.kt index d40c117b..4569162c 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/js5/Js5ChannelHandler.kt +++ b/game/src/main/kotlin/org/openrs2/game/net/js5/Js5ChannelHandler.kt @@ -21,6 +21,7 @@ public class Js5ChannelHandler @Inject constructor( is Js5Request.Group -> service.push(client, msg) is Js5Request.Rekey -> handleRekey(ctx, msg) is Js5Request.Disconnect -> ctx.close() + else -> Unit } }