Cleanup: apply "cascade if..." inspection (+ some others)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
9c06739594
commit
1d2017b0fc
+18
-22
@@ -632,22 +632,20 @@ class ExpressionCodegen(
|
||||
|
||||
val stackElement = data.peek()
|
||||
|
||||
if (stackElement is TryInfo) {
|
||||
//noinspection ConstantConditions
|
||||
genFinallyBlockOrGoto(stackElement, null, afterBreakContinueLabel, data)
|
||||
}
|
||||
else if (stackElement is LoopInfo) {
|
||||
val loop = expression.loop
|
||||
//noinspection ConstantConditions
|
||||
if (loop == stackElement.loop) {
|
||||
val label = if (expression is IrBreak) stackElement.breakLabel else stackElement.continueLabel
|
||||
mv.fixStackAndJump(label)
|
||||
mv.mark(afterBreakContinueLabel)
|
||||
return
|
||||
when (stackElement) {
|
||||
is TryInfo -> //noinspection ConstantConditions
|
||||
genFinallyBlockOrGoto(stackElement, null, afterBreakContinueLabel, data)
|
||||
is LoopInfo -> {
|
||||
val loop = expression.loop
|
||||
//noinspection ConstantConditions
|
||||
if (loop == stackElement.loop) {
|
||||
val label = if (expression is IrBreak) stackElement.breakLabel else stackElement.continueLabel
|
||||
mv.fixStackAndJump(label)
|
||||
mv.mark(afterBreakContinueLabel)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw UnsupportedOperationException("Wrong BlockStackElement in processing stack")
|
||||
else -> throw UnsupportedOperationException("Wrong BlockStackElement in processing stack")
|
||||
}
|
||||
|
||||
data.pop()
|
||||
@@ -829,14 +827,12 @@ class ExpressionCodegen(
|
||||
private fun doFinallyOnReturn(afterReturnLabel: Label, data: BlockInfo) {
|
||||
if (!data.isEmpty()) {
|
||||
val stackElement = data.peek()
|
||||
if (stackElement is TryInfo) {
|
||||
genFinallyBlockOrGoto(stackElement, null, afterReturnLabel, data)
|
||||
}
|
||||
else if (stackElement is LoopInfo) {
|
||||
when (stackElement) {
|
||||
is TryInfo -> genFinallyBlockOrGoto(stackElement, null, afterReturnLabel, data)
|
||||
is LoopInfo -> {
|
||||
|
||||
}
|
||||
else {
|
||||
throw UnsupportedOperationException("Wrong BlockStackElement in processing stack")
|
||||
}
|
||||
else -> throw UnsupportedOperationException("Wrong BlockStackElement in processing stack")
|
||||
}
|
||||
|
||||
data.pop()
|
||||
|
||||
+12
-10
@@ -163,16 +163,18 @@ class StatementGenerator(
|
||||
}
|
||||
else {
|
||||
val label = expression.getTargetLabel()
|
||||
if (label != null) {
|
||||
val labelTarget = getOrFail(BindingContext.LABEL_TARGET, label)
|
||||
val labelTargetDescriptor = getOrFail(BindingContext.DECLARATION_TO_DESCRIPTOR, labelTarget)
|
||||
labelTargetDescriptor as CallableDescriptor
|
||||
}
|
||||
else if (ExpressionTypingUtils.isFunctionLiteral(scopeOwner)) {
|
||||
BindingContextUtils.getContainingFunctionSkipFunctionLiterals(scopeOwner, true).first
|
||||
}
|
||||
else {
|
||||
scopeOwnerAsCallable()
|
||||
when {
|
||||
label != null -> {
|
||||
val labelTarget = getOrFail(BindingContext.LABEL_TARGET, label)
|
||||
val labelTargetDescriptor = getOrFail(BindingContext.DECLARATION_TO_DESCRIPTOR, labelTarget)
|
||||
labelTargetDescriptor as CallableDescriptor
|
||||
}
|
||||
ExpressionTypingUtils.isFunctionLiteral(scopeOwner) -> {
|
||||
BindingContextUtils.getContainingFunctionSkipFunctionLiterals(scopeOwner, true).first
|
||||
}
|
||||
else -> {
|
||||
scopeOwnerAsCallable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user