Initialize return type and use unit type in IrDelegationConstructorCall
(cherry picked from commit faac924)
This commit is contained in:
committed by
Dmitry Petrov
parent
7bd5031eaf
commit
da0a966d65
+1
-1
@@ -235,7 +235,7 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe
|
|||||||
|
|
||||||
val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(classConstructor)
|
val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(classConstructor)
|
||||||
val newCall = IrDelegatingConstructorCallImpl(
|
val newCall = IrDelegatingConstructorCallImpl(
|
||||||
expression.startOffset, expression.endOffset, expression.type, newCallee, newCallee.descriptor,
|
expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee, newCallee.descriptor,
|
||||||
classConstructor.typeParameters.size
|
classConstructor.typeParameters.size
|
||||||
).apply { copyTypeArgumentsFrom(expression) }
|
).apply { copyTypeArgumentsFrom(expression) }
|
||||||
|
|
||||||
|
|||||||
+2
@@ -302,6 +302,8 @@ class ExpressionCodegen(
|
|||||||
mv.athrow()
|
mv.athrow()
|
||||||
} else if (expression.descriptor !is ConstructorDescriptor) {
|
} else if (expression.descriptor !is ConstructorDescriptor) {
|
||||||
return returnType?.run { coerceNotToUnit(callable.returnType, this) } ?: onStack(callable.returnType)
|
return returnType?.run { coerceNotToUnit(callable.returnType, this) } ?: onStack(callable.returnType)
|
||||||
|
} else {
|
||||||
|
return none()
|
||||||
}
|
}
|
||||||
|
|
||||||
return expression.onStack
|
return expression.onStack
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.BRIDGE, bridgeDescriptorForIrFunction)
|
val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.BRIDGE, bridgeDescriptorForIrFunction)
|
||||||
|
irFunction.returnType = bridgeDescriptorForIrFunction.returnType!!.toIrType()!!
|
||||||
irFunction.createParameterDeclarations()
|
irFunction.createParameterDeclarations()
|
||||||
|
|
||||||
context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) {
|
context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) {
|
||||||
|
|||||||
+4
-3
@@ -124,6 +124,7 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
enumConstructor.body!! // will be transformed later
|
enumConstructor.body!! // will be transformed later
|
||||||
).apply {
|
).apply {
|
||||||
parent = enumClass
|
parent = enumClass
|
||||||
|
returnType = loweredConstructorDescriptor.returnType.toIrType()!!
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
loweredEnumConstructors[constructorDescriptor] = this
|
loweredEnumConstructors[constructorDescriptor] = this
|
||||||
constructorDescriptor.valueParameters.forEach {
|
constructorDescriptor.valueParameters.forEach {
|
||||||
@@ -261,7 +262,7 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
val result = IrDelegatingConstructorCallImpl(
|
val result = IrDelegatingConstructorCallImpl(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
enumConstructorCall.symbol.owner.returnType,
|
context.irBuiltIns.unitType,
|
||||||
enumConstructorCall.symbol,
|
enumConstructorCall.symbol,
|
||||||
enumConstructorCall.descriptor,
|
enumConstructorCall.descriptor,
|
||||||
enumConstructorCall.typeArgumentsCount
|
enumConstructorCall.typeArgumentsCount
|
||||||
@@ -297,7 +298,7 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
val result = IrDelegatingConstructorCallImpl(
|
val result = IrDelegatingConstructorCallImpl(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
loweredDelegatedConstructor.symbol.owner.returnType,
|
context.irBuiltIns.unitType,
|
||||||
loweredDelegatedConstructor.symbol,
|
loweredDelegatedConstructor.symbol,
|
||||||
loweredDelegatedConstructor.descriptor,
|
loweredDelegatedConstructor.descriptor,
|
||||||
loweredDelegatedConstructor.typeParameters.size
|
loweredDelegatedConstructor.typeParameters.size
|
||||||
@@ -357,7 +358,7 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
IrDelegatingConstructorCallImpl(
|
IrDelegatingConstructorCallImpl(
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
loweredConstructor.symbol.owner.returnType,
|
context.irBuiltIns.unitType,
|
||||||
loweredConstructor.symbol,
|
loweredConstructor.symbol,
|
||||||
loweredConstructor.descriptor,
|
loweredConstructor.descriptor,
|
||||||
loweredConstructor.typeParameters.size
|
loweredConstructor.typeParameters.size
|
||||||
|
|||||||
+2
-2
@@ -71,7 +71,7 @@ class InterfaceDelegationLowering(val state: GenerationState) : IrElementTransfo
|
|||||||
val defaultImpls = InterfaceLowering.createDefaultImplsClassDescriptor(interfaceDescriptor)
|
val defaultImpls = InterfaceLowering.createDefaultImplsClassDescriptor(interfaceDescriptor)
|
||||||
val defaultImplFun =
|
val defaultImplFun =
|
||||||
InterfaceLowering.createDefaultImplFunDescriptor(defaultImpls, interfaceFun.original, interfaceDescriptor, state.typeMapper)
|
InterfaceLowering.createDefaultImplFunDescriptor(defaultImpls, interfaceFun.original, interfaceDescriptor, state.typeMapper)
|
||||||
|
irFunction.returnType = defaultImplFun.returnType!!.toIrType()!!
|
||||||
val irCallImpl =
|
val irCallImpl =
|
||||||
IrCallImpl(
|
IrCallImpl(
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
@@ -85,7 +85,7 @@ class InterfaceDelegationLowering(val state: GenerationState) : IrElementTransfo
|
|||||||
IrReturnImpl(
|
IrReturnImpl(
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
irFunction.symbol.owner.returnType,
|
irFunction.returnType,
|
||||||
irFunction.symbol,
|
irFunction.symbol,
|
||||||
irCallImpl
|
irCallImpl
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-2
@@ -173,7 +173,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
IrDelegatingConstructorCallImpl(
|
IrDelegatingConstructorCallImpl(
|
||||||
expression.startOffset,
|
expression.startOffset,
|
||||||
expression.endOffset,
|
expression.endOffset,
|
||||||
expression.type,
|
context.irBuiltIns.unitType,
|
||||||
accessorForIr as ClassConstructorDescriptor,
|
accessorForIr as ClassConstructorDescriptor,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
@@ -240,6 +240,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.SYNTHETIC_ACCESSOR,
|
||||||
accessorForIr, body
|
accessorForIr, body
|
||||||
)
|
)
|
||||||
|
syntheticFunction.returnType = accessor.calleeDescriptor.returnType!!.toIrType()!!
|
||||||
syntheticFunction.createParameterDeclarations()
|
syntheticFunction.createParameterDeclarations()
|
||||||
|
|
||||||
val calleeDescriptor = accessor.calleeDescriptor as FunctionDescriptor
|
val calleeDescriptor = accessor.calleeDescriptor as FunctionDescriptor
|
||||||
@@ -250,7 +251,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
val delegationConstructor = createFunctionSymbol(accessor.calleeDescriptor)
|
val delegationConstructor = createFunctionSymbol(accessor.calleeDescriptor)
|
||||||
IrDelegatingConstructorCallImpl(
|
IrDelegatingConstructorCallImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
delegationConstructor.owner.returnType,
|
context.irBuiltIns.unitType,
|
||||||
delegationConstructor as IrConstructorSymbol,
|
delegationConstructor as IrConstructorSymbol,
|
||||||
accessor.calleeDescriptor as ClassConstructorDescriptor
|
accessor.calleeDescriptor as ClassConstructorDescriptor
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-2
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.declarations.IrClass
|
|||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
|
import org.jetbrains.kotlin.ir.types.toIrType
|
||||||
import org.jetbrains.kotlin.ir.util.createParameterDeclarations
|
import org.jetbrains.kotlin.ir.util.createParameterDeclarations
|
||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -85,7 +86,7 @@ class ToArrayLowering(private val context: JvmBackendContext) : ClassLoweringPas
|
|||||||
|
|
||||||
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
||||||
+irReturn(
|
+irReturn(
|
||||||
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor)).apply {
|
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayUtilDescriptor.returnType!!.toIrType()!!).apply {
|
||||||
putValueArgument(
|
putValueArgument(
|
||||||
0,
|
0,
|
||||||
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
||||||
@@ -143,7 +144,7 @@ class ToArrayLowering(private val context: JvmBackendContext) : ClassLoweringPas
|
|||||||
|
|
||||||
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
||||||
+irReturn(
|
+irReturn(
|
||||||
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor)).apply {
|
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayUtilDescriptor.returnType!!.toIrType()!!).apply {
|
||||||
putValueArgument(
|
putValueArgument(
|
||||||
0,
|
0,
|
||||||
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
||||||
|
|||||||
Reference in New Issue
Block a user