diff --git a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/State.kt b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/State.kt index df01641628c..a8a63991378 100644 --- a/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/State.kt +++ b/compiler/ir/ir.interpreter/src/org/jetbrains/kotlin/ir/interpreter/state/State.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.interpreter.exceptions.throwAsUserException +import org.jetbrains.kotlin.ir.interpreter.isFunction import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.defaultType @@ -55,6 +56,13 @@ internal fun State.isSubtypeOf(other: IrType): Boolean { return thisClass.isSubtypeOfClass(otherArgument.typeOrNull!!.classOrNull!!) } + if (this is Lambda) { + if (!other.isFunction()) return false + val typeArgumentsCount = (other as? IrSimpleType)?.arguments?.size ?: return false + val lambdaArgumentCount = this.irFunction.valueParameters.size + 1 // +1 for return type + return typeArgumentsCount == lambdaArgumentCount + } + return this.irClass.defaultType.isSubtypeOfClass(other.classOrNull!!) }