Fix type arguments saving for arrays
This commit is contained in:
committed by
TeamCityServer
parent
7ecf4b17b6
commit
c23e8517b3
+11
-4
@@ -152,7 +152,8 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns, private val bodyMap: Map
|
||||
|
||||
private fun MethodHandle?.invokeMethod(irFunction: IrFunction): ExecutionResult {
|
||||
this ?: return handleIntrinsicMethods(irFunction)
|
||||
val result = withExceptionHandler { this.invokeWithArguments(irFunction.getArgsForMethodInvocation(stack.getAll())) }
|
||||
val argsForMethodInvocation = irFunction.getArgsForMethodInvocation(stack.getAll())
|
||||
val result = withExceptionHandler { this.invokeWithArguments(argsForMethodInvocation) }
|
||||
stack.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
|
||||
return Next
|
||||
@@ -220,8 +221,8 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns, private val bodyMap: Map
|
||||
else -> throw InterpreterError("Unsupported number of arguments for invocation as builtin functions")
|
||||
}
|
||||
}
|
||||
|
||||
stack.pushReturnValue(result.toState(result.getType(irFunction.returnType)))
|
||||
val typeArguments = if (methodName == "CHECK_NOT_NULL") args.single().typeArguments else listOf()
|
||||
stack.pushReturnValue(result.toState(result.getType(irFunction.returnType)).apply { addTypeArguments(typeArguments) })
|
||||
return Next
|
||||
}
|
||||
|
||||
@@ -731,7 +732,13 @@ class IrInterpreter(private val irBuiltIns: IrBuiltIns, private val bodyMap: Map
|
||||
fields.add(Variable(storageProperty.symbol, unsignedArray))
|
||||
}
|
||||
}
|
||||
else -> args.toPrimitiveStateArray(expression.type)
|
||||
else -> args.toPrimitiveStateArray(expression.type).apply {
|
||||
if (expression.type.isArray()) {
|
||||
val arrayTypeArgument = expression.varargElementType.classOrNull?.let { Common(it.owner) }
|
||||
?: stack.getVariable(expression.varargElementType.classifierOrFail).state
|
||||
this.addTypeArguments(listOf(Variable(irBuiltIns.arrayClass.owner.typeParameters.single().symbol, arrayTypeArgument)))
|
||||
}
|
||||
}
|
||||
}
|
||||
stack.pushReturnValue(array)
|
||||
return Next
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.ir.declarations.IrEnumEntry
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.interpreter.exceptions.throwAsUserException
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.types.isCharArray
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
|
||||
internal sealed class IntrinsicBase {
|
||||
@@ -170,7 +171,7 @@ internal object ArrayConstructor : IntrinsicBase() {
|
||||
override fun evaluate(irFunction: IrFunction, stack: Stack, interpret: IrElement.() -> ExecutionResult): ExecutionResult {
|
||||
val sizeDescriptor = irFunction.valueParameters[0].symbol
|
||||
val size = stack.getVariable(sizeDescriptor).state.asInt()
|
||||
val arrayValue = MutableList<Any>(size) { 0 }
|
||||
val arrayValue = MutableList<Any>(size) { if (irFunction.returnType.isCharArray()) 0.toChar() else 0 }
|
||||
|
||||
if (irFunction.valueParameters.size == 2) {
|
||||
val initDescriptor = irFunction.valueParameters[1].symbol
|
||||
|
||||
@@ -53,7 +53,7 @@ internal fun State.isSubtypeOf(other: IrType): Boolean {
|
||||
val thisClass = this.typeArguments.single().state.irClass.symbol
|
||||
val otherArgument = (other as IrSimpleType).arguments.single()
|
||||
if (otherArgument is IrStarProjection) return true
|
||||
return thisClass.isSubtypeOfClass(otherArgument.typeOrNull!!.classOrNull!!)
|
||||
return otherArgument.typeOrNull?.classOrNull?.let { thisClass.isSubtypeOfClass(it) } ?: true
|
||||
}
|
||||
|
||||
if (this is Lambda) {
|
||||
|
||||
Reference in New Issue
Block a user