diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt index e7548991574..94db4d3300e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt @@ -698,7 +698,7 @@ class PsiInlineCodegen( override fun putClosureParametersOnStack(next: LambdaInfo, functionReferenceReceiver: StackValue?) { activeLambda = next when (next) { - is ExpressionLambda -> codegen.pushClosureOnStack(next.classDescriptor, true, this, functionReferenceReceiver) + is PsiExpressionLambda -> codegen.pushClosureOnStack(next.classDescriptor, true, this, functionReferenceReceiver) is DefaultLambda -> rememberCapturedForDefaultLambda(next) else -> throw RuntimeException("Unknown lambda: $next") } @@ -744,7 +744,7 @@ class PsiInlineCodegen( val ktLambda = KtPsiUtil.deparenthesize(expression) assert(isInlinableParameterExpression(ktLambda)) { "Couldn't find inline expression in ${expression.text}" } - return ExpressionLambda( + return PsiExpressionLambda( ktLambda!!, typeMapper, parameter.isCrossinline, getBoundCallableReferenceReceiver(expression) != null ).also { lambda -> val closureInfo = invocationParamBuilder.addNextValueParameter(type, true, null, parameter.index) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.kt index 2f231263413..b918929af82 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.kt @@ -176,12 +176,14 @@ class DefaultLambda( fun Type.boxReceiverForBoundReference() = AsmUtil.boxType(this) -class ExpressionLambda( +abstract class ExpressionLambda(isCrossInline: Boolean): LambdaInfo(isCrossInline) + +class PsiExpressionLambda( expression: KtExpression, private val typeMapper: KotlinTypeMapper, isCrossInline: Boolean, override val isBoundCallableReference: Boolean -) : LambdaInfo(isCrossInline) { +) : ExpressionLambda(isCrossInline) { override val lambdaClassType: Type diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SourceCompilerForInline.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SourceCompilerForInline.kt index 60fb51f1868..fa58b75c0ba 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SourceCompilerForInline.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SourceCompilerForInline.kt @@ -136,6 +136,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid override fun generateLambdaBody(adapter: MethodVisitor, jvmMethodSignature: JvmMethodSignature, lambdaInfo: ExpressionLambda): SMAP { + lambdaInfo as? PsiExpressionLambda ?: error("TODO") val invokeMethodDescriptor = lambdaInfo.invokeMethodDescriptor val closureContext = if (lambdaInfo.isPropertyReference) @@ -157,7 +158,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid context: MethodContext, expression: KtExpression, jvmMethodSignature: JvmMethodSignature, - lambdaInfo: ExpressionLambda? + lambdaInfo: PsiExpressionLambda? ): SMAP { val isLambda = lambdaInfo != null