diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt index 4a1f0642608..63d1a3a62af 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt @@ -122,12 +122,11 @@ fun IrClass.addSimpleDelegatingConstructor( ) constructorDescriptor.returnType = superConstructorDescriptor.returnType - return IrConstructorImpl(startOffset, endOffset, origin, constructorDescriptor).also { constructor -> + return IrConstructorImpl(startOffset, endOffset, origin, constructorDescriptor, this.defaultType).also { constructor -> assert(superConstructor.dispatchReceiverParameter == null) // Inner classes aren't supported. constructor.valueParameters += valueParameters - constructor.returnType = this.defaultType constructor.body = IrBlockBodyImpl( startOffset, endOffset, diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt index 8286affcc0b..71cb20ad203 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt @@ -429,6 +429,7 @@ private fun buildFunctionDeclaration(irFunction: IrFunction, origin: IrDeclarati IrConstructorSymbolImpl(descriptor), irFunction.name, irFunction.visibility, + irFunction.returnType, irFunction.isInline, false, false @@ -449,6 +450,7 @@ private fun buildFunctionDeclaration(irFunction: IrFunction, origin: IrDeclarati name, irFunction.visibility, Modality.FINAL, + irFunction.returnType, irFunction.isInline, false, false, diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt index 86ba536a643..7a151f080ac 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InitializersLowering.kt @@ -137,10 +137,10 @@ class InitializersLowering( IrFunctionImpl( irClass.startOffset, irClass.endOffset, declarationOrigin, staticInitializerDescriptor, + context.irBuiltIns.unitType, IrBlockBodyImpl(irClass.startOffset, irClass.endOffset, staticInitializerStatements.map { it.copy(irClass) }) ).apply { - returnType = context.irBuiltIns.unitType accept(SetDeclarationsParentVisitor, this) } ) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt index c6a10ebc4ba..264666d9484 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InlineClassDeclarationLowering.kt @@ -227,6 +227,12 @@ class InlineClassLowering(val context: BackendContext) { private fun createStaticBodilessMethod(function: IrFunction): IrSimpleFunction { val descriptor = WrappedSimpleFunctionDescriptor() + val returnType = when (function) { + is IrSimpleFunction -> function.returnType + is IrConstructor -> function.parentAsClass.defaultType + else -> error("Unknown function type") + } + return IrFunctionImpl( function.startOffset, function.endOffset, @@ -235,18 +241,14 @@ class InlineClassLowering(val context: BackendContext) { function.name.toInlineClassImplementationName(), function.visibility, Modality.FINAL, + returnType, function.isInline, function.isExternal, (function is IrSimpleFunction && function.isTailrec), (function is IrSimpleFunction && function.isSuspend) ).apply { descriptor.bind(this) - returnType = when (function) { - is IrSimpleFunction -> function.returnType - is IrConstructor -> function.parentAsClass.defaultType - else -> error("Unknown function type") - } - typeParameters += function.typeParameters + copyTypeParametersFrom(function) annotations += function.annotations dispatchReceiverParameter = null extensionReceiverParameter = function.extensionReceiverParameter?.copyTo(this) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt index eac07b74067..0602f1ffc2c 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt @@ -536,6 +536,7 @@ open class LocalDeclarationsLowering( // TODO: change to PRIVATE when issue with CallableReferenceLowering in Jvm BE is fixed if (isJVM) Visibilities.PUBLIC else Visibilities.PRIVATE, Modality.FINAL, + oldDeclaration.returnType, oldDeclaration.isInline, oldDeclaration.isExternal, oldDeclaration.isTailrec, @@ -546,7 +547,6 @@ open class LocalDeclarationsLowering( localFunctionContext.transformedDeclaration = newDeclaration newDeclaration.parent = memberOwner - newDeclaration.returnType = oldDeclaration.returnType newDeclaration.copyTypeParametersFrom(oldDeclaration) newDeclaration.dispatchReceiverParameter = newDispatchReceiverParameter newDeclaration.extensionReceiverParameter = oldDeclaration.extensionReceiverParameter?.run { @@ -615,7 +615,7 @@ open class LocalDeclarationsLowering( val newDeclaration = IrConstructorImpl( oldDeclaration.startOffset, oldDeclaration.endOffset, oldDeclaration.origin, - newSymbol, oldDeclaration.name, loweredConstructorVisibility, oldDeclaration.isInline, + newSymbol, oldDeclaration.name, loweredConstructorVisibility, oldDeclaration.returnType, oldDeclaration.isInline, oldDeclaration.isExternal, oldDeclaration.isPrimary ) @@ -624,7 +624,6 @@ open class LocalDeclarationsLowering( constructorContext.transformedDeclaration = newDeclaration newDeclaration.parent = localClassContext.declaration - newDeclaration.returnType = oldDeclaration.returnType newDeclaration.copyTypeParametersFrom(oldDeclaration) // TODO: should dispatch receiver be copied? diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDeclarationFactory.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDeclarationFactory.kt index f914a6d6694..b7fb09d8dac 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDeclarationFactory.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsDeclarationFactory.kt @@ -95,13 +95,13 @@ class JsDeclarationFactory : DeclarationFactory { symbol, oldConstructor.name, oldConstructor.visibility, + oldConstructor.returnType, oldConstructor.isInline, oldConstructor.isExternal, oldConstructor.isPrimary ).also { descriptor.bind(it) it.parent = oldConstructor.parent - it.returnType = oldConstructor.returnType } newConstructor.copyTypeParametersFrom(oldConstructor) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt index 5be0c7da800..5e70f3c787f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsSharedVariablesManager.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl +import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.name.Name class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclarationsFile: IrFile) : SharedVariablesManager { @@ -169,7 +170,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration val declaration = IrConstructorImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, symbol, - Name.special(""), Visibilities.PUBLIC, false, false, true + Name.special(""), Visibilities.PUBLIC, closureBoxClassDeclaration.defaultType, false, false, true ) descriptor.bind(declaration) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt index 464c2c9da2a..b872ab61dbd 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt @@ -140,13 +140,13 @@ object JsIrBuilder { name, visibility, modality, + returnType, isInline, isExternal, isTailrec, isSuspend ).also { descriptor.bind(it) - it.returnType = returnType it.parent = parent } } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt index 8c55f619dc2..731d7d82a79 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt @@ -417,13 +417,13 @@ class EnumClassTransformer(val context: JsIrBackendContext, private val irClass: loweredConstructorSymbol, enumConstructor.name, enumConstructor.visibility, + enumConstructor.returnType, enumConstructor.isInline, enumConstructor.isExternal, enumConstructor.isPrimary ).apply { loweredConstructorDescriptor.bind(this) parent = enumClass - returnType = enumConstructor.returnType valueParameters += JsIrBuilder.buildValueParameter("name", 0, context.irBuiltIns.stringType).also { it.parent = this } valueParameters += JsIrBuilder.buildValueParameter("ordinal", 1, context.irBuiltIns.intType).also { it.parent = this } copyParameterDeclarationsFrom(enumConstructor) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendFunctionsLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendFunctionsLowering.kt index 7c27727b283..3cfb275b599 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendFunctionsLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/SuspendFunctionsLowering.kt @@ -498,6 +498,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo symbol, Name.special(""), irFunction.visibility, + coroutineClass.defaultType, false, false, false @@ -505,7 +506,6 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo descriptor.bind(declaration) declaration.parent = coroutineClass - declaration.returnType = coroutineClass.defaultType declaration.valueParameters += functionParameters.map { JsIrBuilder.buildValueParameter(it.name, it.index, it.type, it.origin).also { p -> p.parent = declaration } @@ -567,6 +567,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo symbol, Name.special(""), irFunction.visibility, + coroutineClass.defaultType, false, false, false @@ -574,7 +575,6 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo descriptor.bind(declaration) declaration.parent = coroutineClass - declaration.returnType = coroutineClass.defaultType boundParams.mapIndexedTo(declaration.valueParameters) { i, p -> JsIrBuilder.buildValueParameter(p.name, i, p.type, p.origin).also { it.parent = declaration } @@ -627,6 +627,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo Name.identifier("create"), Visibilities.PRIVATE, Modality.FINAL, + coroutineClass.defaultType, false, false, false, @@ -703,6 +704,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo Name.identifier("invoke"), Visibilities.PRIVATE, Modality.FINAL, + irFunction.returnType, false, false, false, @@ -712,7 +714,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo descriptor.bind(declaration) declaration.parent = coroutineClass declaration.returnType = irFunction.returnType - declaration.dispatchReceiverParameter = coroutineClassThis + declaration.dispatchReceiverParameter = coroutineClassThis.copyTo(declaration) declaration.overriddenSymbols += suspendFunctionInvokeFunctionDeclaration.symbol declaration.overriddenSymbols += functionInvokeFunctionDeclaration.symbol @@ -793,6 +795,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo doResumeFunction.name, doResumeFunction.visibility, Modality.FINAL, + context.irBuiltIns.anyNType, doResumeFunction.isInline, doResumeFunction.isExternal, doResumeFunction.isTailrec, @@ -986,4 +989,4 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo scopeStack.peek()!!.add(declaration) } } -} \ No newline at end of file +} diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt index d9882cfa560..3e6ca98bd77 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/DeepCopyIrTreeWithDescriptors.kt @@ -516,6 +516,7 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr endOffset = declaration.endOffset, origin = mapDeclarationOrigin(declaration.origin), descriptor = descriptor, + returnType = declaration.returnType, body = declaration.body?.transform(this@InlineCopyIr, null) ).also { it.setOverrides(context.symbolTable) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/JvmDeclarationFactory.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/JvmDeclarationFactory.kt index a4097eba697..1c0e8dca736 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/JvmDeclarationFactory.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/JvmDeclarationFactory.kt @@ -110,10 +110,15 @@ class JvmDeclarationFactory( oldDescriptor.modality, oldDescriptor.visibility) val symbol = IrConstructorSymbolImpl(newDescriptor) - return IrConstructorImpl(oldConstructor.startOffset, oldConstructor.endOffset, oldConstructor.origin, symbol).also { constructor -> + return IrConstructorImpl( + oldConstructor.startOffset, + oldConstructor.endOffset, + oldConstructor.origin, + symbol, + oldConstructor.returnType + ).also { constructor -> newValueParameters.mapIndexedTo(constructor.valueParameters) { i, v -> constructor.parent = oldConstructor.parent - constructor.returnType = oldConstructor.returnType if (i == 0) { IrValueParameterImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt index a3b38d02c2b..db9e68a98d0 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol +import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType import org.jetbrains.kotlin.ir.types.toIrType import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -163,7 +164,7 @@ class JvmSharedVariablesManager( primitiveRefDescriptorsProvider?.refConstructorSymbol ?: createFunctionSymbol(refConstructor) as IrConstructorSymbol val refConstructorDeclaration = if (refConstructorSymbol.isBound) refConstructorSymbol.owner else - IrConstructorImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, SHARED_VARIABLE_ORIGIN, refConstructorSymbol) + IrConstructorImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, SHARED_VARIABLE_ORIGIN, refConstructorSymbol, IrUninitializedType) val refConstructorTypeArguments = if (primitiveRefDescriptorsProvider != null) null diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index 12431e9b988..8187ed4f898 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -171,6 +171,7 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass { UNDEFINED_OFFSET, IrDeclarationOrigin.DEFINED, IrSimpleFunctionSymbolImpl(descriptor), + returnType = descriptor.returnType!!.toIrType()!!, visibility = visibility, modality = Modality.ABSTRACT ) @@ -207,8 +208,14 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass { bridge.descriptor.returnType, Modality.OPEN, descriptor.visibility ) - val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.BRIDGE, bridgeDescriptorForIrFunction) - irFunction.returnType = bridgeDescriptorForIrFunction.returnType!!.toIrType()!! + val returnType = bridgeDescriptorForIrFunction.returnType!!.toIrType()!! + val irFunction = IrFunctionImpl( + UNDEFINED_OFFSET, + UNDEFINED_OFFSET, + IrDeclarationOrigin.BRIDGE, + bridgeDescriptorForIrFunction, + returnType + ) irFunction.createParameterDeclarations() context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt index 7db3b88d138..9b4798ebb58 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt @@ -348,10 +348,9 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa startOffset = startOffset, endOffset = endOffset, origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, - symbol = symbol - ).apply { + symbol = symbol, returnType = symbol.descriptor.returnType.toIrType()!! - + ).apply { val irBuilder = context.createIrBuilder(this.symbol, startOffset, endOffset) createParameterDeclarations() @@ -432,12 +431,12 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa startOffset = startOffset, endOffset = endOffset, origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, - symbol = ourSymbol + symbol = ourSymbol, + returnType = ourSymbol.descriptor.returnType!!.toIrType()!! ).apply { val function = this val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset) - returnType = ourSymbol.descriptor.returnType!!.toIrType()!! createParameterDeclarations() body = irBuilder.irBlockBody(startOffset, endOffset) { @@ -587,12 +586,12 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa startOffset = startOffset, endOffset = endOffset, origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, - symbol = ourSymbol + symbol = ourSymbol, + returnType = ourSymbol.descriptor.returnType!!.toIrType()!! ).apply { val function = this val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset) - returnType = ourSymbol.descriptor.returnType!!.toIrType()!! createParameterDeclarations() @@ -646,12 +645,12 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa startOffset = startOffset, endOffset = endOffset, origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, - symbol = ourSymbol + symbol = ourSymbol, + returnType = ourSymbol.descriptor.returnType!!.toIrType()!! ).apply { val function = this val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset) - returnType = ourSymbol.descriptor.returnType!!.toIrType()!! createParameterDeclarations() @@ -709,9 +708,9 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa startOffset = startOffset, endOffset = endOffset, origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, - symbol = ourSymbol - ).apply { + symbol = ourSymbol, returnType = symbol.descriptor.returnType!!.toIrType()!! + ).apply { val function = this val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt index fab5f9b49bb..eb91dbfcdda 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt @@ -130,10 +130,10 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass { return IrConstructorImpl( enumConstructor.startOffset, enumConstructor.endOffset, enumConstructor.origin, loweredConstructorDescriptor, + loweredConstructorDescriptor.returnType.toIrType()!!, enumConstructor.body!! // will be transformed later ).apply { parent = enumClass - returnType = loweredConstructorDescriptor.returnType.toIrType()!! createParameterDeclarations() loweredEnumConstructors[constructorDescriptor] = this constructorDescriptor.valueParameters.forEach { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargInvokeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargInvokeLowering.kt index 157b7e8cdb3..42e42dff0b2 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargInvokeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionNVarargInvokeLowering.kt @@ -63,13 +63,13 @@ class FunctionNVarargInvokeLowering(var context: JvmBackendContext) : ClassLower name = Name.identifier("invoke"), visibility = Visibilities.PUBLIC, modality = Modality.OPEN, + returnType = context.irBuiltIns.anyNType, isInline = false, isExternal = false, isTailrec = false, isSuspend = false ).apply { descriptor.bind(this) - returnType = context.irBuiltIns.anyNType dispatchReceiverParameter = irClass.thisReceiver val varargParameterDescriptor = WrappedValueParameterDescriptor() val varargParam = IrValueParameterImpl( diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt index 45008b68ed8..f86e9e64cbd 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceDelegationLowering.kt @@ -77,10 +77,9 @@ class InterfaceDelegationLowering(val context: JvmBackendContext) : IrElementTra UNDEFINED_OFFSET, IrDeclarationOrigin.DEFINED, inheritedFun, - null + defaultImplFun.returnType ).also { it.createParameterDeclarations() - it.returnType = defaultImplFun.returnType } else context.declarationFactory.getDefaultImplsFunction( context.ir.symbols.externalSymbolTable.referenceSimpleFunction( diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt index e7405fc29e2..6085fdebd9c 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt @@ -123,11 +123,11 @@ internal fun FunctionDescriptor.createFunctionAndMapVariables( ) = IrFunctionImpl( oldFunction.startOffset, oldFunction.endOffset, origin, IrSimpleFunctionSymbolImpl(this), - visibility = visibility + visibility = visibility, + returnType = oldFunction.returnType ).apply { parent = parentClass body = oldFunction.body - returnType = oldFunction.returnType createParameterDeclarations(symbolTable) // TODO: do we really need descriptor here? This workaround is about copying `dispatchReceiver` descriptor val mapping: Map = diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt index 738bc83329e..6b40047dcf6 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt @@ -67,17 +67,18 @@ class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : ClassLowe is IrConstructorSymbol -> IrConstructorImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER, - wrapperSymbol + wrapperSymbol, + returnType = target.returnType ) is IrSimpleFunctionSymbol -> IrFunctionImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER, - wrapperSymbol + wrapperSymbol, + returnType = target.returnType ) else -> error("expected IrConstructorSymbol or IrSimpleFunctionSymbol") } - wrapperIrFunction.returnType = target.returnType wrapperIrFunction.createParameterDeclarations() val call = if (target is IrConstructor) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt index 84ebcf3d396..18fa5a0c280 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStaticAnnotationLowering.kt @@ -102,9 +102,9 @@ private class CompanionObjectJvmStaticLowering(val context: JvmBackendContext) : val proxyIrFunction = IrFunctionImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER, - proxyFunctionSymbol + proxyFunctionSymbol, + returnType = target.returnType ) - proxyIrFunction.returnType = target.returnType proxyIrFunction.createParameterDeclarations() proxyIrFunction.body = createProxyBody(target, proxyIrFunction, companion) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt index c6992d48460..470266b448f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl +import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptVoid @@ -104,6 +105,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans IrConstructorSymbolImpl(accessorDescriptor), name, Visibilities.PUBLIC, + IrUninitializedType, isInline = false, isExternal = false, isPrimary = false @@ -159,6 +161,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans source.descriptor.accessorName(), Visibilities.PUBLIC, Modality.FINAL, + IrUninitializedType, isInline = false, isExternal = false, isTailrec = false, @@ -198,6 +201,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans fieldSymbol.descriptor.accessorNameForGetter(), Visibilities.PUBLIC, Modality.FINAL, + fieldSymbol.owner.type, isInline = false, isExternal = false, isTailrec = false, @@ -227,7 +231,6 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans ) } - accessor.returnType = fieldSymbol.owner.type accessor.body = createAccessorBodyForGetter(fieldSymbol.owner, accessor) }.symbol } @@ -257,6 +260,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans fieldSymbol.descriptor.accessorNameForSetter(), Visibilities.PUBLIC, Modality.FINAL, + returnType = context.irBuiltIns.unitType, isInline = false, isExternal = false, isTailrec = false, @@ -303,7 +307,6 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans } ) - accessor.returnType = context.irBuiltIns.unitType accessor.body = createAccessorBodyForSetter(fieldSymbol.owner, accessor) }.symbol } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt index f05d8e1313d..670d1bb5ced 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ToArrayLowering.kt @@ -87,13 +87,20 @@ class ToArrayLowering(private val context: JvmBackendContext) : ClassLoweringPas ) val toArrayUtilDescriptor = createToArrayUtilDescriptor(builtIns, false) + val toArrayType = toArrayUtilDescriptor.returnType!!.toIrType()!! - val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.TO_ARRAY, toArrayDescriptor) + val irFunction = IrFunctionImpl( + UNDEFINED_OFFSET, + UNDEFINED_OFFSET, + JvmLoweredDeclarationOrigin.TO_ARRAY, + toArrayDescriptor, + returnType = toArrayType + ) irFunction.createParameterDeclarations() irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody { +irReturn( - irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayUtilDescriptor.returnType!!.toIrType()!!).apply { + irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayType).apply { putValueArgument( 0, IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol) @@ -145,13 +152,20 @@ class ToArrayLowering(private val context: JvmBackendContext) : ClassLoweringPas ) val toArrayUtilDescriptor = createToArrayUtilDescriptor(builtIns, true) + val toArrayType = toArrayUtilDescriptor.returnType!!.toIrType()!! - val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, JvmLoweredDeclarationOrigin.TO_ARRAY, toArrayDescriptor) + val irFunction = IrFunctionImpl( + UNDEFINED_OFFSET, + UNDEFINED_OFFSET, + JvmLoweredDeclarationOrigin.TO_ARRAY, + toArrayDescriptor, + toArrayType + ) irFunction.createParameterDeclarations() irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody { +irReturn( - irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayUtilDescriptor.returnType!!.toIrType()!!).apply { + irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayType).apply { putValueArgument( 0, IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt index 34282dc5a09..acbbad7385c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/IrMemberFunctionBuilder.kt @@ -42,10 +42,9 @@ class IrMemberFunctionBuilder( lateinit var irFunction: IrFunction inline fun addToClass(body: IrMemberFunctionBuilder.(IrFunction) -> Unit): IrFunction { - irFunction = IrFunctionImpl(startOffset, endOffset, origin, function) + irFunction = IrFunctionImpl(startOffset, endOffset, origin, function, returnType) body(irFunction) irFunction.body = doBuild() - irFunction.returnType = returnType irClass.declarations.add(irFunction) return irFunction } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt index 02688a987bc..722a262a5a8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrConstructorImpl.kt @@ -35,13 +35,14 @@ class IrConstructorImpl( override val symbol: IrConstructorSymbol, name: Name, visibility: Visibility, + returnType: IrType, isInline: Boolean, isExternal: Boolean, override val isPrimary: Boolean ) : IrFunctionBase( startOffset, endOffset, origin, name, - visibility, isInline, isExternal + visibility, isInline, isExternal, returnType ), IrConstructor { @@ -50,11 +51,13 @@ class IrConstructorImpl( endOffset: Int, origin: IrDeclarationOrigin, symbol: IrConstructorSymbol, + returnType: IrType, body: IrBody? = null ) : this( startOffset, endOffset, origin, symbol, symbol.descriptor.name, symbol.descriptor.visibility, + returnType, symbol.descriptor.isInline, symbol.descriptor.isEffectivelyExternal(), symbol.descriptor.isPrimary @@ -66,8 +69,9 @@ class IrConstructorImpl( startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, - descriptor: ClassConstructorDescriptor - ) : this(startOffset, endOffset, origin, IrConstructorSymbolImpl(descriptor)) + descriptor: ClassConstructorDescriptor, + returnType: IrType + ) : this(startOffset, endOffset, origin, IrConstructorSymbolImpl(descriptor), returnType) @Deprecated("Use constructor which takes symbol instead of descriptor") constructor( @@ -75,8 +79,9 @@ class IrConstructorImpl( endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassConstructorDescriptor, + returnType: IrType, body: IrBody? - ) : this(startOffset, endOffset, origin, descriptor) { + ) : this(startOffset, endOffset, origin, descriptor, returnType) { this.body = body } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt index ab3b102bb5d..93404f42ca4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType import org.jetbrains.kotlin.ir.util.transform import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -36,11 +37,19 @@ abstract class IrFunctionBase( override val name: Name, override val visibility: Visibility, override val isInline: Boolean, - override val isExternal: Boolean + override val isExternal: Boolean, + returnType: IrType ) : IrDeclarationBase(startOffset, endOffset, origin), IrFunction { + final override var returnType: IrType = returnType + get() = if (field === IrUninitializedType) { + error("Return type is not initialized") + } else { + field + } + override val typeParameters: MutableList = SmartList() override var dispatchReceiverParameter: IrValueParameter? = null @@ -49,8 +58,6 @@ abstract class IrFunctionBase( final override var body: IrBody? = null - final override lateinit var returnType: IrType - override fun acceptChildren(visitor: IrElementVisitor, data: D) { typeParameters.forEach { it.accept(visitor, data) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt index 7081a64653e..f6dd581723c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt @@ -27,12 +27,13 @@ class IrFunctionImpl( name: Name, visibility: Visibility, override val modality: Modality, + returnType: IrType, isInline: Boolean, isExternal: Boolean, override val isTailrec: Boolean, override val isSuspend: Boolean ) : - IrFunctionBase(startOffset, endOffset, origin, name, visibility, isInline, isExternal), + IrFunctionBase(startOffset, endOffset, origin, name, visibility, isInline, isExternal, returnType), IrSimpleFunction { constructor( @@ -40,6 +41,7 @@ class IrFunctionImpl( endOffset: Int, origin: IrDeclarationOrigin, symbol: IrSimpleFunctionSymbol, + returnType: IrType, visibility: Visibility = symbol.descriptor.visibility, modality: Modality = symbol.descriptor.modality ) : this( @@ -47,6 +49,7 @@ class IrFunctionImpl( symbol.descriptor.name, visibility, modality, + returnType, symbol.descriptor.isInline, symbol.descriptor.isExternal, symbol.descriptor.isTailrec, @@ -63,10 +66,11 @@ class IrFunctionImpl( startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, - descriptor: FunctionDescriptor + descriptor: FunctionDescriptor, + returnType: IrType ) : this( startOffset, endOffset, origin, - IrSimpleFunctionSymbolImpl(descriptor) + IrSimpleFunctionSymbolImpl(descriptor), returnType ) constructor( @@ -74,8 +78,9 @@ class IrFunctionImpl( endOffset: Int, origin: IrDeclarationOrigin, descriptor: FunctionDescriptor, + returnType: IrType, body: IrBody? - ) : this(startOffset, endOffset, origin, descriptor) { + ) : this(startOffset, endOffset, origin, descriptor, returnType) { this.body = body } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt index 55fbdd8cf45..b1080de4e65 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt @@ -38,4 +38,9 @@ val IrType.originalKotlinType: KotlinType? get() = safeAs()?.kotlinType -object IrStarProjectionImpl : IrStarProjection \ No newline at end of file +object IrStarProjectionImpl : IrStarProjection + +@Deprecated("Hack to temporary cover late type initialization") +object IrUninitializedType : IrType { + override val annotations: List = emptyList() +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt index ba61db6670e..cad83d6cc33 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt @@ -116,6 +116,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { declaration.startOffset, declaration.endOffset, mapDeclarationOrigin(declaration.origin), mapFunctionDeclaration(declaration.descriptor), + declaration.returnType, // TODO declaration.body?.transform() ).transformParameters(declaration).apply { transformAnnotations(declaration) @@ -126,7 +127,6 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { else IrSimpleFunctionSymbolImpl(overriddenDescriptor.original) } - returnType = declaration.returnType // TODO } override fun visitConstructor(declaration: IrConstructor): IrConstructor = @@ -134,10 +134,10 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { declaration.startOffset, declaration.endOffset, mapDeclarationOrigin(declaration.origin), mapConstructorDeclaration(declaration.descriptor), + declaration.returnType, // TODO declaration.body?.transform() ).transformParameters(declaration).apply { transformAnnotations(declaration) - returnType = declaration.returnType // TODO } protected fun T.transformTypeParameters( diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt index df2ef496a34..356a232e22c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt @@ -155,6 +155,7 @@ open class DeepCopyIrTreeWithSymbols( symbolRenamer.getFunctionName(declaration.symbol), declaration.visibility, declaration.modality, + declaration.returnType, declaration.isInline, declaration.isExternal, declaration.isTailrec, @@ -173,6 +174,7 @@ open class DeepCopyIrTreeWithSymbols( symbolRemapper.getDeclaredConstructor(declaration.symbol), declaration.name, declaration.visibility, + declaration.returnType, declaration.isInline, declaration.isExternal, declaration.isPrimary diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index d45a5b223fb..3b60c5db090 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.symbols.impl.* import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptVoid @@ -235,7 +236,7 @@ open class SymbolTable : ReferenceSymbolTable { endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassConstructorDescriptor, - constructorFactory: (IrConstructorSymbol) -> IrConstructor = { IrConstructorImpl(startOffset, endOffset, origin, it) } + constructorFactory: (IrConstructorSymbol) -> IrConstructor = { IrConstructorImpl(startOffset, endOffset, origin, it, IrUninitializedType) } ): IrConstructor = constructorSymbolTable.declare( descriptor, @@ -299,7 +300,7 @@ open class SymbolTable : ReferenceSymbolTable { endOffset: Int, origin: IrDeclarationOrigin, descriptor: FunctionDescriptor, - functionFactory: (IrSimpleFunctionSymbol) -> IrSimpleFunction = { IrFunctionImpl(startOffset, endOffset, origin, it) } + functionFactory: (IrSimpleFunctionSymbol) -> IrSimpleFunction = { IrFunctionImpl(startOffset, endOffset, origin, it, IrUninitializedType) } ): IrSimpleFunction { return simpleFunctionSymbolTable.declare( descriptor,