[IR] Add returnType to consturcotrs of IrFunctionBase
This commit is contained in:
@@ -122,12 +122,11 @@ fun IrClass.addSimpleDelegatingConstructor(
|
|||||||
)
|
)
|
||||||
constructorDescriptor.returnType = superConstructorDescriptor.returnType
|
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.
|
assert(superConstructor.dispatchReceiverParameter == null) // Inner classes aren't supported.
|
||||||
|
|
||||||
constructor.valueParameters += valueParameters
|
constructor.valueParameters += valueParameters
|
||||||
constructor.returnType = this.defaultType
|
|
||||||
|
|
||||||
constructor.body = IrBlockBodyImpl(
|
constructor.body = IrBlockBodyImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
|
|||||||
+2
@@ -429,6 +429,7 @@ private fun buildFunctionDeclaration(irFunction: IrFunction, origin: IrDeclarati
|
|||||||
IrConstructorSymbolImpl(descriptor),
|
IrConstructorSymbolImpl(descriptor),
|
||||||
irFunction.name,
|
irFunction.name,
|
||||||
irFunction.visibility,
|
irFunction.visibility,
|
||||||
|
irFunction.returnType,
|
||||||
irFunction.isInline,
|
irFunction.isInline,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
@@ -449,6 +450,7 @@ private fun buildFunctionDeclaration(irFunction: IrFunction, origin: IrDeclarati
|
|||||||
name,
|
name,
|
||||||
irFunction.visibility,
|
irFunction.visibility,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
irFunction.returnType,
|
||||||
irFunction.isInline,
|
irFunction.isInline,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
|||||||
+1
-1
@@ -137,10 +137,10 @@ class InitializersLowering(
|
|||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
irClass.startOffset, irClass.endOffset, declarationOrigin,
|
irClass.startOffset, irClass.endOffset, declarationOrigin,
|
||||||
staticInitializerDescriptor,
|
staticInitializerDescriptor,
|
||||||
|
context.irBuiltIns.unitType,
|
||||||
IrBlockBodyImpl(irClass.startOffset, irClass.endOffset,
|
IrBlockBodyImpl(irClass.startOffset, irClass.endOffset,
|
||||||
staticInitializerStatements.map { it.copy(irClass) })
|
staticInitializerStatements.map { it.copy(irClass) })
|
||||||
).apply {
|
).apply {
|
||||||
returnType = context.irBuiltIns.unitType
|
|
||||||
accept(SetDeclarationsParentVisitor, this)
|
accept(SetDeclarationsParentVisitor, this)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+8
-6
@@ -227,6 +227,12 @@ class InlineClassLowering(val context: BackendContext) {
|
|||||||
|
|
||||||
private fun createStaticBodilessMethod(function: IrFunction): IrSimpleFunction {
|
private fun createStaticBodilessMethod(function: IrFunction): IrSimpleFunction {
|
||||||
val descriptor = WrappedSimpleFunctionDescriptor()
|
val descriptor = WrappedSimpleFunctionDescriptor()
|
||||||
|
val returnType = when (function) {
|
||||||
|
is IrSimpleFunction -> function.returnType
|
||||||
|
is IrConstructor -> function.parentAsClass.defaultType
|
||||||
|
else -> error("Unknown function type")
|
||||||
|
}
|
||||||
|
|
||||||
return IrFunctionImpl(
|
return IrFunctionImpl(
|
||||||
function.startOffset,
|
function.startOffset,
|
||||||
function.endOffset,
|
function.endOffset,
|
||||||
@@ -235,18 +241,14 @@ class InlineClassLowering(val context: BackendContext) {
|
|||||||
function.name.toInlineClassImplementationName(),
|
function.name.toInlineClassImplementationName(),
|
||||||
function.visibility,
|
function.visibility,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
returnType,
|
||||||
function.isInline,
|
function.isInline,
|
||||||
function.isExternal,
|
function.isExternal,
|
||||||
(function is IrSimpleFunction && function.isTailrec),
|
(function is IrSimpleFunction && function.isTailrec),
|
||||||
(function is IrSimpleFunction && function.isSuspend)
|
(function is IrSimpleFunction && function.isSuspend)
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
descriptor.bind(this)
|
||||||
returnType = when (function) {
|
copyTypeParametersFrom(function)
|
||||||
is IrSimpleFunction -> function.returnType
|
|
||||||
is IrConstructor -> function.parentAsClass.defaultType
|
|
||||||
else -> error("Unknown function type")
|
|
||||||
}
|
|
||||||
typeParameters += function.typeParameters
|
|
||||||
annotations += function.annotations
|
annotations += function.annotations
|
||||||
dispatchReceiverParameter = null
|
dispatchReceiverParameter = null
|
||||||
extensionReceiverParameter = function.extensionReceiverParameter?.copyTo(this)
|
extensionReceiverParameter = function.extensionReceiverParameter?.copyTo(this)
|
||||||
|
|||||||
+2
-3
@@ -536,6 +536,7 @@ open class LocalDeclarationsLowering(
|
|||||||
// TODO: change to PRIVATE when issue with CallableReferenceLowering in Jvm BE is fixed
|
// TODO: change to PRIVATE when issue with CallableReferenceLowering in Jvm BE is fixed
|
||||||
if (isJVM) Visibilities.PUBLIC else Visibilities.PRIVATE,
|
if (isJVM) Visibilities.PUBLIC else Visibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
oldDeclaration.returnType,
|
||||||
oldDeclaration.isInline,
|
oldDeclaration.isInline,
|
||||||
oldDeclaration.isExternal,
|
oldDeclaration.isExternal,
|
||||||
oldDeclaration.isTailrec,
|
oldDeclaration.isTailrec,
|
||||||
@@ -546,7 +547,6 @@ open class LocalDeclarationsLowering(
|
|||||||
localFunctionContext.transformedDeclaration = newDeclaration
|
localFunctionContext.transformedDeclaration = newDeclaration
|
||||||
|
|
||||||
newDeclaration.parent = memberOwner
|
newDeclaration.parent = memberOwner
|
||||||
newDeclaration.returnType = oldDeclaration.returnType
|
|
||||||
newDeclaration.copyTypeParametersFrom(oldDeclaration)
|
newDeclaration.copyTypeParametersFrom(oldDeclaration)
|
||||||
newDeclaration.dispatchReceiverParameter = newDispatchReceiverParameter
|
newDeclaration.dispatchReceiverParameter = newDispatchReceiverParameter
|
||||||
newDeclaration.extensionReceiverParameter = oldDeclaration.extensionReceiverParameter?.run {
|
newDeclaration.extensionReceiverParameter = oldDeclaration.extensionReceiverParameter?.run {
|
||||||
@@ -615,7 +615,7 @@ open class LocalDeclarationsLowering(
|
|||||||
|
|
||||||
val newDeclaration = IrConstructorImpl(
|
val newDeclaration = IrConstructorImpl(
|
||||||
oldDeclaration.startOffset, oldDeclaration.endOffset, oldDeclaration.origin,
|
oldDeclaration.startOffset, oldDeclaration.endOffset, oldDeclaration.origin,
|
||||||
newSymbol, oldDeclaration.name, loweredConstructorVisibility, oldDeclaration.isInline,
|
newSymbol, oldDeclaration.name, loweredConstructorVisibility, oldDeclaration.returnType, oldDeclaration.isInline,
|
||||||
oldDeclaration.isExternal, oldDeclaration.isPrimary
|
oldDeclaration.isExternal, oldDeclaration.isPrimary
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -624,7 +624,6 @@ open class LocalDeclarationsLowering(
|
|||||||
constructorContext.transformedDeclaration = newDeclaration
|
constructorContext.transformedDeclaration = newDeclaration
|
||||||
|
|
||||||
newDeclaration.parent = localClassContext.declaration
|
newDeclaration.parent = localClassContext.declaration
|
||||||
newDeclaration.returnType = oldDeclaration.returnType
|
|
||||||
newDeclaration.copyTypeParametersFrom(oldDeclaration)
|
newDeclaration.copyTypeParametersFrom(oldDeclaration)
|
||||||
|
|
||||||
// TODO: should dispatch receiver be copied?
|
// TODO: should dispatch receiver be copied?
|
||||||
|
|||||||
+1
-1
@@ -95,13 +95,13 @@ class JsDeclarationFactory : DeclarationFactory {
|
|||||||
symbol,
|
symbol,
|
||||||
oldConstructor.name,
|
oldConstructor.name,
|
||||||
oldConstructor.visibility,
|
oldConstructor.visibility,
|
||||||
|
oldConstructor.returnType,
|
||||||
oldConstructor.isInline,
|
oldConstructor.isInline,
|
||||||
oldConstructor.isExternal,
|
oldConstructor.isExternal,
|
||||||
oldConstructor.isPrimary
|
oldConstructor.isPrimary
|
||||||
).also {
|
).also {
|
||||||
descriptor.bind(it)
|
descriptor.bind(it)
|
||||||
it.parent = oldConstructor.parent
|
it.parent = oldConstructor.parent
|
||||||
it.returnType = oldConstructor.returnType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newConstructor.copyTypeParametersFrom(oldConstructor)
|
newConstructor.copyTypeParametersFrom(oldConstructor)
|
||||||
|
|||||||
+2
-1
@@ -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.symbols.impl.IrVariableSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||||
|
import org.jetbrains.kotlin.ir.util.defaultType
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclarationsFile: IrFile) : SharedVariablesManager {
|
class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclarationsFile: IrFile) : SharedVariablesManager {
|
||||||
@@ -169,7 +170,7 @@ class JsSharedVariablesManager(val builtIns: IrBuiltIns, val implicitDeclaration
|
|||||||
|
|
||||||
val declaration = IrConstructorImpl(
|
val declaration = IrConstructorImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, symbol,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, JsLoweredDeclarationOrigin.JS_CLOSURE_BOX_CLASS_DECLARATION, symbol,
|
||||||
Name.special("<init>"), Visibilities.PUBLIC, false, false, true
|
Name.special("<init>"), Visibilities.PUBLIC, closureBoxClassDeclaration.defaultType, false, false, true
|
||||||
)
|
)
|
||||||
|
|
||||||
descriptor.bind(declaration)
|
descriptor.bind(declaration)
|
||||||
|
|||||||
@@ -140,13 +140,13 @@ object JsIrBuilder {
|
|||||||
name,
|
name,
|
||||||
visibility,
|
visibility,
|
||||||
modality,
|
modality,
|
||||||
|
returnType,
|
||||||
isInline,
|
isInline,
|
||||||
isExternal,
|
isExternal,
|
||||||
isTailrec,
|
isTailrec,
|
||||||
isSuspend
|
isSuspend
|
||||||
).also {
|
).also {
|
||||||
descriptor.bind(it)
|
descriptor.bind(it)
|
||||||
it.returnType = returnType
|
|
||||||
it.parent = parent
|
it.parent = parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -417,13 +417,13 @@ class EnumClassTransformer(val context: JsIrBackendContext, private val irClass:
|
|||||||
loweredConstructorSymbol,
|
loweredConstructorSymbol,
|
||||||
enumConstructor.name,
|
enumConstructor.name,
|
||||||
enumConstructor.visibility,
|
enumConstructor.visibility,
|
||||||
|
enumConstructor.returnType,
|
||||||
enumConstructor.isInline,
|
enumConstructor.isInline,
|
||||||
enumConstructor.isExternal,
|
enumConstructor.isExternal,
|
||||||
enumConstructor.isPrimary
|
enumConstructor.isPrimary
|
||||||
).apply {
|
).apply {
|
||||||
loweredConstructorDescriptor.bind(this)
|
loweredConstructorDescriptor.bind(this)
|
||||||
parent = enumClass
|
parent = enumClass
|
||||||
returnType = enumConstructor.returnType
|
|
||||||
valueParameters += JsIrBuilder.buildValueParameter("name", 0, context.irBuiltIns.stringType).also { it.parent = this }
|
valueParameters += JsIrBuilder.buildValueParameter("name", 0, context.irBuiltIns.stringType).also { it.parent = this }
|
||||||
valueParameters += JsIrBuilder.buildValueParameter("ordinal", 1, context.irBuiltIns.intType).also { it.parent = this }
|
valueParameters += JsIrBuilder.buildValueParameter("ordinal", 1, context.irBuiltIns.intType).also { it.parent = this }
|
||||||
copyParameterDeclarationsFrom(enumConstructor)
|
copyParameterDeclarationsFrom(enumConstructor)
|
||||||
|
|||||||
+7
-4
@@ -498,6 +498,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
symbol,
|
symbol,
|
||||||
Name.special("<init>"),
|
Name.special("<init>"),
|
||||||
irFunction.visibility,
|
irFunction.visibility,
|
||||||
|
coroutineClass.defaultType,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
@@ -505,7 +506,6 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
|
|
||||||
descriptor.bind(declaration)
|
descriptor.bind(declaration)
|
||||||
declaration.parent = coroutineClass
|
declaration.parent = coroutineClass
|
||||||
declaration.returnType = coroutineClass.defaultType
|
|
||||||
|
|
||||||
declaration.valueParameters += functionParameters.map {
|
declaration.valueParameters += functionParameters.map {
|
||||||
JsIrBuilder.buildValueParameter(it.name, it.index, it.type, it.origin).also { p -> p.parent = declaration }
|
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,
|
symbol,
|
||||||
Name.special("<init>"),
|
Name.special("<init>"),
|
||||||
irFunction.visibility,
|
irFunction.visibility,
|
||||||
|
coroutineClass.defaultType,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
@@ -574,7 +575,6 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
|
|
||||||
descriptor.bind(declaration)
|
descriptor.bind(declaration)
|
||||||
declaration.parent = coroutineClass
|
declaration.parent = coroutineClass
|
||||||
declaration.returnType = coroutineClass.defaultType
|
|
||||||
|
|
||||||
boundParams.mapIndexedTo(declaration.valueParameters) { i, p ->
|
boundParams.mapIndexedTo(declaration.valueParameters) { i, p ->
|
||||||
JsIrBuilder.buildValueParameter(p.name, i, p.type, p.origin).also { it.parent = declaration }
|
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"),
|
Name.identifier("create"),
|
||||||
Visibilities.PRIVATE,
|
Visibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
coroutineClass.defaultType,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@@ -703,6 +704,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
Name.identifier("invoke"),
|
Name.identifier("invoke"),
|
||||||
Visibilities.PRIVATE,
|
Visibilities.PRIVATE,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
irFunction.returnType,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
@@ -712,7 +714,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
descriptor.bind(declaration)
|
descriptor.bind(declaration)
|
||||||
declaration.parent = coroutineClass
|
declaration.parent = coroutineClass
|
||||||
declaration.returnType = irFunction.returnType
|
declaration.returnType = irFunction.returnType
|
||||||
declaration.dispatchReceiverParameter = coroutineClassThis
|
declaration.dispatchReceiverParameter = coroutineClassThis.copyTo(declaration)
|
||||||
|
|
||||||
declaration.overriddenSymbols += suspendFunctionInvokeFunctionDeclaration.symbol
|
declaration.overriddenSymbols += suspendFunctionInvokeFunctionDeclaration.symbol
|
||||||
declaration.overriddenSymbols += functionInvokeFunctionDeclaration.symbol
|
declaration.overriddenSymbols += functionInvokeFunctionDeclaration.symbol
|
||||||
@@ -793,6 +795,7 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
doResumeFunction.name,
|
doResumeFunction.name,
|
||||||
doResumeFunction.visibility,
|
doResumeFunction.visibility,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
context.irBuiltIns.anyNType,
|
||||||
doResumeFunction.isInline,
|
doResumeFunction.isInline,
|
||||||
doResumeFunction.isExternal,
|
doResumeFunction.isExternal,
|
||||||
doResumeFunction.isTailrec,
|
doResumeFunction.isTailrec,
|
||||||
@@ -986,4 +989,4 @@ internal class SuspendFunctionsLowering(val context: JsIrBackendContext): FileLo
|
|||||||
scopeStack.peek()!!.add(declaration)
|
scopeStack.peek()!!.add(declaration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -516,6 +516,7 @@ internal class DeepCopyIrTreeWithDescriptors(val targetDescriptor: FunctionDescr
|
|||||||
endOffset = declaration.endOffset,
|
endOffset = declaration.endOffset,
|
||||||
origin = mapDeclarationOrigin(declaration.origin),
|
origin = mapDeclarationOrigin(declaration.origin),
|
||||||
descriptor = descriptor,
|
descriptor = descriptor,
|
||||||
|
returnType = declaration.returnType,
|
||||||
body = declaration.body?.transform(this@InlineCopyIr, null)
|
body = declaration.body?.transform(this@InlineCopyIr, null)
|
||||||
).also {
|
).also {
|
||||||
it.setOverrides(context.symbolTable)
|
it.setOverrides(context.symbolTable)
|
||||||
|
|||||||
+7
-2
@@ -110,10 +110,15 @@ class JvmDeclarationFactory(
|
|||||||
oldDescriptor.modality,
|
oldDescriptor.modality,
|
||||||
oldDescriptor.visibility)
|
oldDescriptor.visibility)
|
||||||
val symbol = IrConstructorSymbolImpl(newDescriptor)
|
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 ->
|
newValueParameters.mapIndexedTo(constructor.valueParameters) { i, v ->
|
||||||
constructor.parent = oldConstructor.parent
|
constructor.parent = oldConstructor.parent
|
||||||
constructor.returnType = oldConstructor.returnType
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
IrValueParameterImpl(
|
IrValueParameterImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
|
|||||||
+2
-1
@@ -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.IrFieldSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol
|
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.ir.types.toIrType
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -163,7 +164,7 @@ class JvmSharedVariablesManager(
|
|||||||
primitiveRefDescriptorsProvider?.refConstructorSymbol ?: createFunctionSymbol(refConstructor) as IrConstructorSymbol
|
primitiveRefDescriptorsProvider?.refConstructorSymbol ?: createFunctionSymbol(refConstructor) as IrConstructorSymbol
|
||||||
|
|
||||||
val refConstructorDeclaration = if (refConstructorSymbol.isBound) refConstructorSymbol.owner else
|
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 =
|
val refConstructorTypeArguments =
|
||||||
if (primitiveRefDescriptorsProvider != null) null
|
if (primitiveRefDescriptorsProvider != null) null
|
||||||
|
|||||||
+9
-2
@@ -171,6 +171,7 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor),
|
IrSimpleFunctionSymbolImpl(descriptor),
|
||||||
|
returnType = descriptor.returnType!!.toIrType()!!,
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
modality = Modality.ABSTRACT
|
modality = Modality.ABSTRACT
|
||||||
)
|
)
|
||||||
@@ -207,8 +208,14 @@ class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
bridge.descriptor.returnType, Modality.OPEN, descriptor.visibility
|
bridge.descriptor.returnType, Modality.OPEN, descriptor.visibility
|
||||||
)
|
)
|
||||||
|
|
||||||
val irFunction = IrFunctionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.BRIDGE, bridgeDescriptorForIrFunction)
|
val returnType = bridgeDescriptorForIrFunction.returnType!!.toIrType()!!
|
||||||
irFunction.returnType = bridgeDescriptorForIrFunction.returnType!!.toIrType()!!
|
val irFunction = IrFunctionImpl(
|
||||||
|
UNDEFINED_OFFSET,
|
||||||
|
UNDEFINED_OFFSET,
|
||||||
|
IrDeclarationOrigin.BRIDGE,
|
||||||
|
bridgeDescriptorForIrFunction,
|
||||||
|
returnType
|
||||||
|
)
|
||||||
irFunction.createParameterDeclarations()
|
irFunction.createParameterDeclarations()
|
||||||
|
|
||||||
context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) {
|
context.createIrBuilder(irFunction.symbol).irBlockBody(irFunction) {
|
||||||
|
|||||||
+10
-11
@@ -348,10 +348,9 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
symbol = symbol
|
symbol = symbol,
|
||||||
).apply {
|
|
||||||
returnType = symbol.descriptor.returnType.toIrType()!!
|
returnType = symbol.descriptor.returnType.toIrType()!!
|
||||||
|
).apply {
|
||||||
val irBuilder = context.createIrBuilder(this.symbol, startOffset, endOffset)
|
val irBuilder = context.createIrBuilder(this.symbol, startOffset, endOffset)
|
||||||
|
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
@@ -432,12 +431,12 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
symbol = ourSymbol
|
symbol = ourSymbol,
|
||||||
|
returnType = ourSymbol.descriptor.returnType!!.toIrType()!!
|
||||||
).apply {
|
).apply {
|
||||||
|
|
||||||
val function = this
|
val function = this
|
||||||
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
||||||
returnType = ourSymbol.descriptor.returnType!!.toIrType()!!
|
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
|
|
||||||
body = irBuilder.irBlockBody(startOffset, endOffset) {
|
body = irBuilder.irBlockBody(startOffset, endOffset) {
|
||||||
@@ -587,12 +586,12 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
symbol = ourSymbol
|
symbol = ourSymbol,
|
||||||
|
returnType = ourSymbol.descriptor.returnType!!.toIrType()!!
|
||||||
).apply {
|
).apply {
|
||||||
|
|
||||||
val function = this
|
val function = this
|
||||||
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
||||||
returnType = ourSymbol.descriptor.returnType!!.toIrType()!!
|
|
||||||
|
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
|
|
||||||
@@ -646,12 +645,12 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
symbol = ourSymbol
|
symbol = ourSymbol,
|
||||||
|
returnType = ourSymbol.descriptor.returnType!!.toIrType()!!
|
||||||
).apply {
|
).apply {
|
||||||
|
|
||||||
val function = this
|
val function = this
|
||||||
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
||||||
returnType = ourSymbol.descriptor.returnType!!.toIrType()!!
|
|
||||||
|
|
||||||
createParameterDeclarations()
|
createParameterDeclarations()
|
||||||
|
|
||||||
@@ -709,9 +708,9 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
|
|||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
origin = DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
|
||||||
symbol = ourSymbol
|
symbol = ourSymbol,
|
||||||
).apply {
|
|
||||||
returnType = symbol.descriptor.returnType!!.toIrType()!!
|
returnType = symbol.descriptor.returnType!!.toIrType()!!
|
||||||
|
).apply {
|
||||||
val function = this
|
val function = this
|
||||||
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
val irBuilder = context.createIrBuilder(function.symbol, startOffset, endOffset)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -130,10 +130,10 @@ class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringPass {
|
|||||||
return IrConstructorImpl(
|
return IrConstructorImpl(
|
||||||
enumConstructor.startOffset, enumConstructor.endOffset, enumConstructor.origin,
|
enumConstructor.startOffset, enumConstructor.endOffset, enumConstructor.origin,
|
||||||
loweredConstructorDescriptor,
|
loweredConstructorDescriptor,
|
||||||
|
loweredConstructorDescriptor.returnType.toIrType()!!,
|
||||||
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 {
|
||||||
|
|||||||
+1
-1
@@ -63,13 +63,13 @@ class FunctionNVarargInvokeLowering(var context: JvmBackendContext) : ClassLower
|
|||||||
name = Name.identifier("invoke"),
|
name = Name.identifier("invoke"),
|
||||||
visibility = Visibilities.PUBLIC,
|
visibility = Visibilities.PUBLIC,
|
||||||
modality = Modality.OPEN,
|
modality = Modality.OPEN,
|
||||||
|
returnType = context.irBuiltIns.anyNType,
|
||||||
isInline = false,
|
isInline = false,
|
||||||
isExternal = false,
|
isExternal = false,
|
||||||
isTailrec = false,
|
isTailrec = false,
|
||||||
isSuspend = false
|
isSuspend = false
|
||||||
).apply {
|
).apply {
|
||||||
descriptor.bind(this)
|
descriptor.bind(this)
|
||||||
returnType = context.irBuiltIns.anyNType
|
|
||||||
dispatchReceiverParameter = irClass.thisReceiver
|
dispatchReceiverParameter = irClass.thisReceiver
|
||||||
val varargParameterDescriptor = WrappedValueParameterDescriptor()
|
val varargParameterDescriptor = WrappedValueParameterDescriptor()
|
||||||
val varargParam = IrValueParameterImpl(
|
val varargParam = IrValueParameterImpl(
|
||||||
|
|||||||
+1
-2
@@ -77,10 +77,9 @@ class InterfaceDelegationLowering(val context: JvmBackendContext) : IrElementTra
|
|||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
IrDeclarationOrigin.DEFINED,
|
IrDeclarationOrigin.DEFINED,
|
||||||
inheritedFun,
|
inheritedFun,
|
||||||
null
|
defaultImplFun.returnType
|
||||||
).also {
|
).also {
|
||||||
it.createParameterDeclarations()
|
it.createParameterDeclarations()
|
||||||
it.returnType = defaultImplFun.returnType
|
|
||||||
}
|
}
|
||||||
else context.declarationFactory.getDefaultImplsFunction(
|
else context.declarationFactory.getDefaultImplsFunction(
|
||||||
context.ir.symbols.externalSymbolTable.referenceSimpleFunction(
|
context.ir.symbols.externalSymbolTable.referenceSimpleFunction(
|
||||||
|
|||||||
+2
-2
@@ -123,11 +123,11 @@ internal fun FunctionDescriptor.createFunctionAndMapVariables(
|
|||||||
) =
|
) =
|
||||||
IrFunctionImpl(
|
IrFunctionImpl(
|
||||||
oldFunction.startOffset, oldFunction.endOffset, origin, IrSimpleFunctionSymbolImpl(this),
|
oldFunction.startOffset, oldFunction.endOffset, origin, IrSimpleFunctionSymbolImpl(this),
|
||||||
visibility = visibility
|
visibility = visibility,
|
||||||
|
returnType = oldFunction.returnType
|
||||||
).apply {
|
).apply {
|
||||||
parent = parentClass
|
parent = parentClass
|
||||||
body = oldFunction.body
|
body = oldFunction.body
|
||||||
returnType = oldFunction.returnType
|
|
||||||
createParameterDeclarations(symbolTable)
|
createParameterDeclarations(symbolTable)
|
||||||
// TODO: do we really need descriptor here? This workaround is about copying `dispatchReceiver` descriptor
|
// TODO: do we really need descriptor here? This workaround is about copying `dispatchReceiver` descriptor
|
||||||
val mapping: Map<ValueDescriptor, IrValueParameter> =
|
val mapping: Map<ValueDescriptor, IrValueParameter> =
|
||||||
|
|||||||
+4
-3
@@ -67,17 +67,18 @@ class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : ClassLowe
|
|||||||
is IrConstructorSymbol -> IrConstructorImpl(
|
is IrConstructorSymbol -> IrConstructorImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
|
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
|
||||||
wrapperSymbol
|
wrapperSymbol,
|
||||||
|
returnType = target.returnType
|
||||||
)
|
)
|
||||||
is IrSimpleFunctionSymbol -> IrFunctionImpl(
|
is IrSimpleFunctionSymbol -> IrFunctionImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
|
JvmLoweredDeclarationOrigin.JVM_OVERLOADS_WRAPPER,
|
||||||
wrapperSymbol
|
wrapperSymbol,
|
||||||
|
returnType = target.returnType
|
||||||
)
|
)
|
||||||
else -> error("expected IrConstructorSymbol or IrSimpleFunctionSymbol")
|
else -> error("expected IrConstructorSymbol or IrSimpleFunctionSymbol")
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapperIrFunction.returnType = target.returnType
|
|
||||||
wrapperIrFunction.createParameterDeclarations()
|
wrapperIrFunction.createParameterDeclarations()
|
||||||
|
|
||||||
val call = if (target is IrConstructor)
|
val call = if (target is IrConstructor)
|
||||||
|
|||||||
+2
-2
@@ -102,9 +102,9 @@ private class CompanionObjectJvmStaticLowering(val context: JvmBackendContext) :
|
|||||||
val proxyIrFunction = IrFunctionImpl(
|
val proxyIrFunction = IrFunctionImpl(
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER,
|
JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER,
|
||||||
proxyFunctionSymbol
|
proxyFunctionSymbol,
|
||||||
|
returnType = target.returnType
|
||||||
)
|
)
|
||||||
proxyIrFunction.returnType = target.returnType
|
|
||||||
proxyIrFunction.createParameterDeclarations()
|
proxyIrFunction.createParameterDeclarations()
|
||||||
|
|
||||||
proxyIrFunction.body = createProxyBody(target, proxyIrFunction, companion)
|
proxyIrFunction.body = createProxyBody(target, proxyIrFunction, companion)
|
||||||
|
|||||||
+5
-2
@@ -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.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
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.util.*
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
@@ -104,6 +105,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans
|
|||||||
IrConstructorSymbolImpl(accessorDescriptor),
|
IrConstructorSymbolImpl(accessorDescriptor),
|
||||||
name,
|
name,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC,
|
||||||
|
IrUninitializedType,
|
||||||
isInline = false,
|
isInline = false,
|
||||||
isExternal = false,
|
isExternal = false,
|
||||||
isPrimary = false
|
isPrimary = false
|
||||||
@@ -159,6 +161,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans
|
|||||||
source.descriptor.accessorName(),
|
source.descriptor.accessorName(),
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
IrUninitializedType,
|
||||||
isInline = false,
|
isInline = false,
|
||||||
isExternal = false,
|
isExternal = false,
|
||||||
isTailrec = false,
|
isTailrec = false,
|
||||||
@@ -198,6 +201,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans
|
|||||||
fieldSymbol.descriptor.accessorNameForGetter(),
|
fieldSymbol.descriptor.accessorNameForGetter(),
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
fieldSymbol.owner.type,
|
||||||
isInline = false,
|
isInline = false,
|
||||||
isExternal = false,
|
isExternal = false,
|
||||||
isTailrec = false,
|
isTailrec = false,
|
||||||
@@ -227,7 +231,6 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
accessor.returnType = fieldSymbol.owner.type
|
|
||||||
accessor.body = createAccessorBodyForGetter(fieldSymbol.owner, accessor)
|
accessor.body = createAccessorBodyForGetter(fieldSymbol.owner, accessor)
|
||||||
}.symbol
|
}.symbol
|
||||||
}
|
}
|
||||||
@@ -257,6 +260,7 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans
|
|||||||
fieldSymbol.descriptor.accessorNameForSetter(),
|
fieldSymbol.descriptor.accessorNameForSetter(),
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC,
|
||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
|
returnType = context.irBuiltIns.unitType,
|
||||||
isInline = false,
|
isInline = false,
|
||||||
isExternal = false,
|
isExternal = false,
|
||||||
isTailrec = false,
|
isTailrec = false,
|
||||||
@@ -303,7 +307,6 @@ class SyntheticAccessorLowering(val context: JvmBackendContext) : IrElementTrans
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
accessor.returnType = context.irBuiltIns.unitType
|
|
||||||
accessor.body = createAccessorBodyForSetter(fieldSymbol.owner, accessor)
|
accessor.body = createAccessorBodyForSetter(fieldSymbol.owner, accessor)
|
||||||
}.symbol
|
}.symbol
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-4
@@ -87,13 +87,20 @@ class ToArrayLowering(private val context: JvmBackendContext) : ClassLoweringPas
|
|||||||
)
|
)
|
||||||
|
|
||||||
val toArrayUtilDescriptor = createToArrayUtilDescriptor(builtIns, false)
|
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.createParameterDeclarations()
|
||||||
|
|
||||||
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
||||||
+irReturn(
|
+irReturn(
|
||||||
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayUtilDescriptor.returnType!!.toIrType()!!).apply {
|
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayType).apply {
|
||||||
putValueArgument(
|
putValueArgument(
|
||||||
0,
|
0,
|
||||||
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
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 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.createParameterDeclarations()
|
||||||
|
|
||||||
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
irFunction.body = context.createIrBuilder(irFunction.symbol).irBlockBody {
|
||||||
+irReturn(
|
+irReturn(
|
||||||
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayUtilDescriptor.returnType!!.toIrType()!!).apply {
|
irCall(IrSimpleFunctionSymbolImpl(toArrayUtilDescriptor), toArrayType).apply {
|
||||||
putValueArgument(
|
putValueArgument(
|
||||||
0,
|
0,
|
||||||
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irFunction.dispatchReceiverParameter!!.symbol)
|
||||||
|
|||||||
@@ -42,10 +42,9 @@ class IrMemberFunctionBuilder(
|
|||||||
lateinit var irFunction: IrFunction
|
lateinit var irFunction: IrFunction
|
||||||
|
|
||||||
inline fun addToClass(body: IrMemberFunctionBuilder.(IrFunction) -> Unit): IrFunction {
|
inline fun addToClass(body: IrMemberFunctionBuilder.(IrFunction) -> Unit): IrFunction {
|
||||||
irFunction = IrFunctionImpl(startOffset, endOffset, origin, function)
|
irFunction = IrFunctionImpl(startOffset, endOffset, origin, function, returnType)
|
||||||
body(irFunction)
|
body(irFunction)
|
||||||
irFunction.body = doBuild()
|
irFunction.body = doBuild()
|
||||||
irFunction.returnType = returnType
|
|
||||||
irClass.declarations.add(irFunction)
|
irClass.declarations.add(irFunction)
|
||||||
return irFunction
|
return irFunction
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -35,13 +35,14 @@ class IrConstructorImpl(
|
|||||||
override val symbol: IrConstructorSymbol,
|
override val symbol: IrConstructorSymbol,
|
||||||
name: Name,
|
name: Name,
|
||||||
visibility: Visibility,
|
visibility: Visibility,
|
||||||
|
returnType: IrType,
|
||||||
isInline: Boolean,
|
isInline: Boolean,
|
||||||
isExternal: Boolean,
|
isExternal: Boolean,
|
||||||
override val isPrimary: Boolean
|
override val isPrimary: Boolean
|
||||||
) :
|
) :
|
||||||
IrFunctionBase(
|
IrFunctionBase(
|
||||||
startOffset, endOffset, origin, name,
|
startOffset, endOffset, origin, name,
|
||||||
visibility, isInline, isExternal
|
visibility, isInline, isExternal, returnType
|
||||||
),
|
),
|
||||||
IrConstructor {
|
IrConstructor {
|
||||||
|
|
||||||
@@ -50,11 +51,13 @@ class IrConstructorImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
symbol: IrConstructorSymbol,
|
symbol: IrConstructorSymbol,
|
||||||
|
returnType: IrType,
|
||||||
body: IrBody? = null
|
body: IrBody? = null
|
||||||
) : this(
|
) : this(
|
||||||
startOffset, endOffset, origin, symbol,
|
startOffset, endOffset, origin, symbol,
|
||||||
symbol.descriptor.name,
|
symbol.descriptor.name,
|
||||||
symbol.descriptor.visibility,
|
symbol.descriptor.visibility,
|
||||||
|
returnType,
|
||||||
symbol.descriptor.isInline,
|
symbol.descriptor.isInline,
|
||||||
symbol.descriptor.isEffectivelyExternal(),
|
symbol.descriptor.isEffectivelyExternal(),
|
||||||
symbol.descriptor.isPrimary
|
symbol.descriptor.isPrimary
|
||||||
@@ -66,8 +69,9 @@ class IrConstructorImpl(
|
|||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
descriptor: ClassConstructorDescriptor
|
descriptor: ClassConstructorDescriptor,
|
||||||
) : this(startOffset, endOffset, origin, IrConstructorSymbolImpl(descriptor))
|
returnType: IrType
|
||||||
|
) : this(startOffset, endOffset, origin, IrConstructorSymbolImpl(descriptor), returnType)
|
||||||
|
|
||||||
@Deprecated("Use constructor which takes symbol instead of descriptor")
|
@Deprecated("Use constructor which takes symbol instead of descriptor")
|
||||||
constructor(
|
constructor(
|
||||||
@@ -75,8 +79,9 @@ class IrConstructorImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
descriptor: ClassConstructorDescriptor,
|
descriptor: ClassConstructorDescriptor,
|
||||||
|
returnType: IrType,
|
||||||
body: IrBody?
|
body: IrBody?
|
||||||
) : this(startOffset, endOffset, origin, descriptor) {
|
) : this(startOffset, endOffset, origin, descriptor, returnType) {
|
||||||
this.body = body
|
this.body = body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-3
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
|||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
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.util.transform
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
@@ -36,11 +37,19 @@ abstract class IrFunctionBase(
|
|||||||
override val name: Name,
|
override val name: Name,
|
||||||
override val visibility: Visibility,
|
override val visibility: Visibility,
|
||||||
override val isInline: Boolean,
|
override val isInline: Boolean,
|
||||||
override val isExternal: Boolean
|
override val isExternal: Boolean,
|
||||||
|
returnType: IrType
|
||||||
) :
|
) :
|
||||||
IrDeclarationBase(startOffset, endOffset, origin),
|
IrDeclarationBase(startOffset, endOffset, origin),
|
||||||
IrFunction {
|
IrFunction {
|
||||||
|
|
||||||
|
final override var returnType: IrType = returnType
|
||||||
|
get() = if (field === IrUninitializedType) {
|
||||||
|
error("Return type is not initialized")
|
||||||
|
} else {
|
||||||
|
field
|
||||||
|
}
|
||||||
|
|
||||||
override val typeParameters: MutableList<IrTypeParameter> = SmartList()
|
override val typeParameters: MutableList<IrTypeParameter> = SmartList()
|
||||||
|
|
||||||
override var dispatchReceiverParameter: IrValueParameter? = null
|
override var dispatchReceiverParameter: IrValueParameter? = null
|
||||||
@@ -49,8 +58,6 @@ abstract class IrFunctionBase(
|
|||||||
|
|
||||||
final override var body: IrBody? = null
|
final override var body: IrBody? = null
|
||||||
|
|
||||||
final override lateinit var returnType: IrType
|
|
||||||
|
|
||||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||||
typeParameters.forEach { it.accept(visitor, data) }
|
typeParameters.forEach { it.accept(visitor, data) }
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,13 @@ class IrFunctionImpl(
|
|||||||
name: Name,
|
name: Name,
|
||||||
visibility: Visibility,
|
visibility: Visibility,
|
||||||
override val modality: Modality,
|
override val modality: Modality,
|
||||||
|
returnType: IrType,
|
||||||
isInline: Boolean,
|
isInline: Boolean,
|
||||||
isExternal: Boolean,
|
isExternal: Boolean,
|
||||||
override val isTailrec: Boolean,
|
override val isTailrec: Boolean,
|
||||||
override val isSuspend: Boolean
|
override val isSuspend: Boolean
|
||||||
) :
|
) :
|
||||||
IrFunctionBase(startOffset, endOffset, origin, name, visibility, isInline, isExternal),
|
IrFunctionBase(startOffset, endOffset, origin, name, visibility, isInline, isExternal, returnType),
|
||||||
IrSimpleFunction {
|
IrSimpleFunction {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -40,6 +41,7 @@ class IrFunctionImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
symbol: IrSimpleFunctionSymbol,
|
symbol: IrSimpleFunctionSymbol,
|
||||||
|
returnType: IrType,
|
||||||
visibility: Visibility = symbol.descriptor.visibility,
|
visibility: Visibility = symbol.descriptor.visibility,
|
||||||
modality: Modality = symbol.descriptor.modality
|
modality: Modality = symbol.descriptor.modality
|
||||||
) : this(
|
) : this(
|
||||||
@@ -47,6 +49,7 @@ class IrFunctionImpl(
|
|||||||
symbol.descriptor.name,
|
symbol.descriptor.name,
|
||||||
visibility,
|
visibility,
|
||||||
modality,
|
modality,
|
||||||
|
returnType,
|
||||||
symbol.descriptor.isInline,
|
symbol.descriptor.isInline,
|
||||||
symbol.descriptor.isExternal,
|
symbol.descriptor.isExternal,
|
||||||
symbol.descriptor.isTailrec,
|
symbol.descriptor.isTailrec,
|
||||||
@@ -63,10 +66,11 @@ class IrFunctionImpl(
|
|||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
descriptor: FunctionDescriptor
|
descriptor: FunctionDescriptor,
|
||||||
|
returnType: IrType
|
||||||
) : this(
|
) : this(
|
||||||
startOffset, endOffset, origin,
|
startOffset, endOffset, origin,
|
||||||
IrSimpleFunctionSymbolImpl(descriptor)
|
IrSimpleFunctionSymbolImpl(descriptor), returnType
|
||||||
)
|
)
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -74,8 +78,9 @@ class IrFunctionImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
descriptor: FunctionDescriptor,
|
descriptor: FunctionDescriptor,
|
||||||
|
returnType: IrType,
|
||||||
body: IrBody?
|
body: IrBody?
|
||||||
) : this(startOffset, endOffset, origin, descriptor) {
|
) : this(startOffset, endOffset, origin, descriptor, returnType) {
|
||||||
this.body = body
|
this.body = body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,4 +38,9 @@ val IrType.originalKotlinType: KotlinType?
|
|||||||
get() = safeAs<IrTypeBase>()?.kotlinType
|
get() = safeAs<IrTypeBase>()?.kotlinType
|
||||||
|
|
||||||
|
|
||||||
object IrStarProjectionImpl : IrStarProjection
|
object IrStarProjectionImpl : IrStarProjection
|
||||||
|
|
||||||
|
@Deprecated("Hack to temporary cover late type initialization")
|
||||||
|
object IrUninitializedType : IrType {
|
||||||
|
override val annotations: List<IrCall> = emptyList()
|
||||||
|
}
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
|||||||
declaration.startOffset, declaration.endOffset,
|
declaration.startOffset, declaration.endOffset,
|
||||||
mapDeclarationOrigin(declaration.origin),
|
mapDeclarationOrigin(declaration.origin),
|
||||||
mapFunctionDeclaration(declaration.descriptor),
|
mapFunctionDeclaration(declaration.descriptor),
|
||||||
|
declaration.returnType, // TODO
|
||||||
declaration.body?.transform()
|
declaration.body?.transform()
|
||||||
).transformParameters(declaration).apply {
|
).transformParameters(declaration).apply {
|
||||||
transformAnnotations(declaration)
|
transformAnnotations(declaration)
|
||||||
@@ -126,7 +127,6 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
|||||||
else
|
else
|
||||||
IrSimpleFunctionSymbolImpl(overriddenDescriptor.original)
|
IrSimpleFunctionSymbolImpl(overriddenDescriptor.original)
|
||||||
}
|
}
|
||||||
returnType = declaration.returnType // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitConstructor(declaration: IrConstructor): IrConstructor =
|
override fun visitConstructor(declaration: IrConstructor): IrConstructor =
|
||||||
@@ -134,10 +134,10 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
|||||||
declaration.startOffset, declaration.endOffset,
|
declaration.startOffset, declaration.endOffset,
|
||||||
mapDeclarationOrigin(declaration.origin),
|
mapDeclarationOrigin(declaration.origin),
|
||||||
mapConstructorDeclaration(declaration.descriptor),
|
mapConstructorDeclaration(declaration.descriptor),
|
||||||
|
declaration.returnType, // TODO
|
||||||
declaration.body?.transform()
|
declaration.body?.transform()
|
||||||
).transformParameters(declaration).apply {
|
).transformParameters(declaration).apply {
|
||||||
transformAnnotations(declaration)
|
transformAnnotations(declaration)
|
||||||
returnType = declaration.returnType // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun <T : IrTypeParametersContainer> T.transformTypeParameters(
|
protected fun <T : IrTypeParametersContainer> T.transformTypeParameters(
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ open class DeepCopyIrTreeWithSymbols(
|
|||||||
symbolRenamer.getFunctionName(declaration.symbol),
|
symbolRenamer.getFunctionName(declaration.symbol),
|
||||||
declaration.visibility,
|
declaration.visibility,
|
||||||
declaration.modality,
|
declaration.modality,
|
||||||
|
declaration.returnType,
|
||||||
declaration.isInline,
|
declaration.isInline,
|
||||||
declaration.isExternal,
|
declaration.isExternal,
|
||||||
declaration.isTailrec,
|
declaration.isTailrec,
|
||||||
@@ -173,6 +174,7 @@ open class DeepCopyIrTreeWithSymbols(
|
|||||||
symbolRemapper.getDeclaredConstructor(declaration.symbol),
|
symbolRemapper.getDeclaredConstructor(declaration.symbol),
|
||||||
declaration.name,
|
declaration.name,
|
||||||
declaration.visibility,
|
declaration.visibility,
|
||||||
|
declaration.returnType,
|
||||||
declaration.isInline,
|
declaration.isInline,
|
||||||
declaration.isExternal,
|
declaration.isExternal,
|
||||||
declaration.isPrimary
|
declaration.isPrimary
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
|||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.*
|
import org.jetbrains.kotlin.ir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
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.IrElementVisitorVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
@@ -235,7 +236,7 @@ open class SymbolTable : ReferenceSymbolTable {
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
descriptor: ClassConstructorDescriptor,
|
descriptor: ClassConstructorDescriptor,
|
||||||
constructorFactory: (IrConstructorSymbol) -> IrConstructor = { IrConstructorImpl(startOffset, endOffset, origin, it) }
|
constructorFactory: (IrConstructorSymbol) -> IrConstructor = { IrConstructorImpl(startOffset, endOffset, origin, it, IrUninitializedType) }
|
||||||
): IrConstructor =
|
): IrConstructor =
|
||||||
constructorSymbolTable.declare(
|
constructorSymbolTable.declare(
|
||||||
descriptor,
|
descriptor,
|
||||||
@@ -299,7 +300,7 @@ open class SymbolTable : ReferenceSymbolTable {
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
origin: IrDeclarationOrigin,
|
origin: IrDeclarationOrigin,
|
||||||
descriptor: FunctionDescriptor,
|
descriptor: FunctionDescriptor,
|
||||||
functionFactory: (IrSimpleFunctionSymbol) -> IrSimpleFunction = { IrFunctionImpl(startOffset, endOffset, origin, it) }
|
functionFactory: (IrSimpleFunctionSymbol) -> IrSimpleFunction = { IrFunctionImpl(startOffset, endOffset, origin, it, IrUninitializedType) }
|
||||||
): IrSimpleFunction {
|
): IrSimpleFunction {
|
||||||
return simpleFunctionSymbolTable.declare(
|
return simpleFunctionSymbolTable.declare(
|
||||||
descriptor,
|
descriptor,
|
||||||
|
|||||||
Reference in New Issue
Block a user