Minor: JvmBuiltinOptimizationLowering.kt: reformat & fix warnings

This commit is contained in:
Dmitry Petrov
2019-11-25 16:53:26 +03:00
parent 20fb519f1a
commit c676b58c14
@@ -53,18 +53,21 @@ class JvmBuiltinOptimizationLowering(val context: JvmBackendContext) : FileLower
dispatchReceiverParameter != null dispatchReceiverParameter != null
private fun getOperandsIfCallToEqeqOrEquals(call: IrCall): Pair<IrExpression, IrExpression>? { private fun getOperandsIfCallToEqeqOrEquals(call: IrCall): Pair<IrExpression, IrExpression>? =
if (call.symbol == context.irBuiltIns.eqeqSymbol) { when {
call.symbol == context.irBuiltIns.eqeqSymbol -> {
val left = call.getValueArgument(0)!! val left = call.getValueArgument(0)!!
val right = call.getValueArgument(1)!! val right = call.getValueArgument(1)!!
return left to right left to right
} else if (call.symbol.owner.isObjectEquals) { }
call.symbol.owner.isObjectEquals -> {
val left = call.dispatchReceiver!! val left = call.dispatchReceiver!!
val right = call.getValueArgument(0)!! val right = call.getValueArgument(0)!!
return left to right left to right
} else {
return null;
} }
else -> null
} }
override fun lower(irFile: IrFile) { override fun lower(irFile: IrFile) {
@@ -116,7 +119,7 @@ class JvmBuiltinOptimizationLowering(val context: JvmBackendContext) : FileLower
val isCompilerGenerated = expression.origin == null val isCompilerGenerated = expression.origin == null
expression.transformChildrenVoid(this) expression.transformChildrenVoid(this)
// Remove all branches with constant false condition. // Remove all branches with constant false condition.
expression.branches.removeIf() { expression.branches.removeIf {
it.condition.isFalseConst() && isCompilerGenerated it.condition.isFalseConst() && isCompilerGenerated
} }
if (expression.origin == IrStatementOrigin.ANDAND) { if (expression.origin == IrStatementOrigin.ANDAND) {
@@ -248,7 +251,8 @@ class JvmBuiltinOptimizationLowering(val context: JvmBackendContext) : FileLower
if (first is IrVariable if (first is IrVariable
&& first.origin == IrDeclarationOrigin.IR_TEMPORARY_VARIABLE && first.origin == IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
&& second is IrGetValue && second is IrGetValue
&& first.symbol == second.symbol) { && first.symbol == second.symbol
) {
statements.clear() statements.clear()
first.initializer?.let { statements.add(it) } first.initializer?.let { statements.add(it) }
} }