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