diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt index 7e97f7a1339..f1202c3d07e 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt @@ -52,11 +52,13 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass { private fun createOuterThisField() { outerThisFieldDescriptor = context.descriptorsFactory.getOuterThisFieldDescriptor(irClass.descriptor) - irClass.declarations.add(IrFieldImpl( - irClass.startOffset, irClass.endOffset, - FIELD_FOR_OUTER_THIS, - outerThisFieldDescriptor - )) + irClass.declarations.add( + IrFieldImpl( + irClass.startOffset, irClass.endOffset, + FIELD_FOR_OUTER_THIS, + outerThisFieldDescriptor + ) + ) } private fun lowerConstructors() { @@ -100,14 +102,13 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass { IrGetValueImpl(startOffset, endOffset, outerThisValueParameter) ) ) - } - else { + } else { // Delegating constructor: invoke old constructor with dispatch receiver '$outer' - val delegatingConstructorCall = (blockBody.statements.find { it is IrDelegatingConstructorCall } ?: - throw AssertionError("Delegating constructor call expected: ${irConstructor.dump()}") - ) as IrDelegatingConstructorCall + val delegatingConstructorCall = (blockBody.statements.find { it is IrDelegatingConstructorCall } + ?: throw AssertionError("Delegating constructor call expected: ${irConstructor.dump()}") + ) as IrDelegatingConstructorCall delegatingConstructorCall.dispatchReceiver = IrGetValueImpl( - delegatingConstructorCall.startOffset, delegatingConstructorCall.endOffset, outerThisValueParameter + delegatingConstructorCall.startOffset, delegatingConstructorCall.endOffset, outerThisValueParameter ) } @@ -124,14 +125,13 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass { override fun visitClass(declaration: IrClass): IrStatement = - //TODO: maybe add another transformer that skips specified elements - declaration + //TODO: maybe add another transformer that skips specified elements + declaration override fun visitGetValue(expression: IrGetValue): IrExpression { expression.transformChildrenVoid(this) - val implicitThisClass = expression.descriptor.getClassDescriptorForImplicitThis() ?: - return expression + val implicitThisClass = expression.descriptor.getClassDescriptorForImplicitThis() ?: return expression if (implicitThisClass == classDescriptor) return expression @@ -154,7 +154,7 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass { val outer = innerClass.containingDeclaration innerClass = outer as? ClassDescriptor ?: - throw AssertionError("Unexpected containing declaration for inner class $innerClass: $outer") + throw AssertionError("Unexpected containing declaration for inner class $innerClass: $outer") } return irThis @@ -186,13 +186,13 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(callee) val newCall = IrCallImpl( - expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor, - null, // TODO type arguments map - expression.origin + expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor, + null, // TODO type arguments map + expression.origin ) newCall.putValueArgument(0, dispatchReceiver) - for (i in 1 .. newCallee.descriptor.valueParameters.lastIndex) { + for (i in 1..newCallee.descriptor.valueParameters.lastIndex) { newCall.putValueArgument(i, expression.getValueArgument(i - 1)) } @@ -208,12 +208,12 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(callee) val newCall = IrDelegatingConstructorCallImpl( - expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor, - null // TODO type arguments map + expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor, + null // TODO type arguments map ) newCall.putValueArgument(0, dispatchReceiver) - for (i in 1 .. newCallee.descriptor.valueParameters.lastIndex) { + for (i in 1..newCallee.descriptor.valueParameters.lastIndex) { newCall.putValueArgument(i, expression.getValueArgument(i - 1)) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 6aa5cef5b32..9410f419334 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -51,7 +51,7 @@ import java.util.* open class ExpressionInfo(val expression: IrExpression) -class LoopInfo(val loop: IrLoop, val continueLabel: Label, val breakLabel: Label): ExpressionInfo(loop) +class LoopInfo(val loop: IrLoop, val continueLabel: Label, val breakLabel: Label) : ExpressionInfo(loop) class TryInfo(val tryBlock: IrTry) : ExpressionInfo(tryBlock) { val gaps = mutableListOf