Fixed wrong expressions types
This commit is contained in:
+16
-9
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.backend.konan.Context
|
|||||||
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
|
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.descriptors.ValueDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.builders.irGet
|
import org.jetbrains.kotlin.ir.builders.irGet
|
||||||
@@ -23,12 +22,10 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrReturnableBlockSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrReturnableBlockSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
@@ -238,9 +235,9 @@ internal class FunctionInlining(val context: Context) : IrElementTransformerVoid
|
|||||||
|
|
||||||
val immediateCall = with(expression) {
|
val immediateCall = with(expression) {
|
||||||
if (function is IrConstructor)
|
if (function is IrConstructor)
|
||||||
IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, function.symbol)
|
IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, function.returnType, function.symbol)
|
||||||
else
|
else
|
||||||
IrCallImpl(startOffset, endOffset, type, functionArgument.symbol)
|
IrCallImpl(startOffset, endOffset, function.returnType, functionArgument.symbol)
|
||||||
}.apply {
|
}.apply {
|
||||||
functionParameters.forEach {
|
functionParameters.forEach {
|
||||||
val argument =
|
val argument =
|
||||||
@@ -249,15 +246,19 @@ internal class FunctionInlining(val context: Context) : IrElementTransformerVoid
|
|||||||
else
|
else
|
||||||
valueParameters[unboundIndex++].second
|
valueParameters[unboundIndex++].second
|
||||||
when (it) {
|
when (it) {
|
||||||
function.dispatchReceiverParameter -> this.dispatchReceiver = argument
|
function.dispatchReceiverParameter ->
|
||||||
function.extensionReceiverParameter -> this.extensionReceiver = argument
|
this.dispatchReceiver = argument.implicitCastIfNeededTo(function.dispatchReceiverParameter!!.type)
|
||||||
else -> putValueArgument(it.index, argument)
|
|
||||||
|
function.extensionReceiverParameter ->
|
||||||
|
this.extensionReceiver = argument.implicitCastIfNeededTo(function.extensionReceiverParameter!!.type)
|
||||||
|
|
||||||
|
else -> putValueArgument(it.index, argument.implicitCastIfNeededTo(function.valueParameters[it.index].type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(unboundIndex == valueParameters.size) { "Not all arguments of <invoke> are used" }
|
assert(unboundIndex == valueParameters.size) { "Not all arguments of <invoke> are used" }
|
||||||
for (index in 0 until functionArgument.typeArgumentsCount)
|
for (index in 0 until functionArgument.typeArgumentsCount)
|
||||||
putTypeArgument(index, functionArgument.getTypeArgument(index))
|
putTypeArgument(index, functionArgument.getTypeArgument(index))
|
||||||
}
|
}.implicitCastIfNeededTo(expression.type)
|
||||||
return this@FunctionInlining.visitExpression(super.visitExpression(immediateCall))
|
return this@FunctionInlining.visitExpression(super.visitExpression(immediateCall))
|
||||||
}
|
}
|
||||||
if (functionArgument !is IrBlock)
|
if (functionArgument !is IrBlock)
|
||||||
@@ -273,6 +274,12 @@ internal class FunctionInlining(val context: Context) : IrElementTransformerVoid
|
|||||||
override fun visitElement(element: IrElement) = element.accept(this, null)
|
override fun visitElement(element: IrElement) = element.accept(this, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrExpression.implicitCastIfNeededTo(type: IrType) =
|
||||||
|
if (type == this.type)
|
||||||
|
this
|
||||||
|
else
|
||||||
|
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.IMPLICIT_CAST, type, this)
|
||||||
|
|
||||||
private fun isLambdaCall(irCall: IrCall): Boolean {
|
private fun isLambdaCall(irCall: IrCall): Boolean {
|
||||||
val callee = irCall.symbol.owner
|
val callee = irCall.symbol.owner
|
||||||
val dispatchReceiver = callee.dispatchReceiverParameter ?: return false
|
val dispatchReceiver = callee.dispatchReceiverParameter ?: return false
|
||||||
|
|||||||
+2
-2
@@ -100,9 +100,9 @@ internal class PostInlineLowering(val context: Context) : FileLoweringPass {
|
|||||||
// Basic Multilingual Plane, so we could just append data "as is".
|
// Basic Multilingual Plane, so we could just append data "as is".
|
||||||
builder.append(value.toChar())
|
builder.append(value.toChar())
|
||||||
}
|
}
|
||||||
expression.putValueArgument(0, IrConstImpl<String>(
|
expression.putValueArgument(0, IrConstImpl(
|
||||||
expression.startOffset, expression.endOffset,
|
expression.startOffset, expression.endOffset,
|
||||||
context.ir.symbols.immutableBlob.typeWithoutArguments,
|
context.irBuiltIns.stringType,
|
||||||
IrConstKind.String, builder.toString()))
|
IrConstKind.String, builder.toString()))
|
||||||
} else if (expression.symbol.owner.isTypeOfIntrinsic()) {
|
} else if (expression.symbol.owner.isTypeOfIntrinsic()) {
|
||||||
val type = expression.getTypeArgument(0)
|
val type = expression.getTypeArgument(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user