Minor. Reformat
This commit is contained in:
+23
-23
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user