Minor, add debug info to assertion in AddContinuationLowering
This commit is contained in:
+9
-7
@@ -9,10 +9,7 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
|||||||
import org.jetbrains.kotlin.backend.common.descriptors.WrappedFunctionDescriptorWithContainerSource
|
import org.jetbrains.kotlin.backend.common.descriptors.WrappedFunctionDescriptorWithContainerSource
|
||||||
import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor
|
import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
|
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedName
|
||||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
import org.jetbrains.kotlin.backend.common.ir.*
|
||||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.isSuspend
|
|
||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
import org.jetbrains.kotlin.backend.common.lower.parents
|
import org.jetbrains.kotlin.backend.common.lower.parents
|
||||||
import org.jetbrains.kotlin.backend.common.peek
|
import org.jetbrains.kotlin.backend.common.peek
|
||||||
@@ -470,13 +467,13 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getContinuationFromCaller(): IrGetValue {
|
private fun getContinuationFromCaller(): IrGetValue? {
|
||||||
val caller = functionStack.peek()!!
|
val caller = functionStack.peek()!!
|
||||||
val continuationParameter =
|
val continuationParameter =
|
||||||
if (caller.isSuspend) caller.valueParameters.last().symbol
|
if (caller.isSuspend) caller.valueParameters.last().symbol
|
||||||
else if (caller.name.asString() == INVOKE_SUSPEND_METHOD_NAME && caller.parent in context.suspendLambdaToOriginalFunctionMap)
|
else if (caller.name.asString() == INVOKE_SUSPEND_METHOD_NAME && caller.parent in context.suspendLambdaToOriginalFunctionMap)
|
||||||
caller.dispatchReceiverParameter!!.symbol
|
caller.dispatchReceiverParameter!!.symbol
|
||||||
else error("suspend call outside suspend context")
|
else return null
|
||||||
return IrGetValueImpl(
|
return IrGetValueImpl(
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
UNDEFINED_OFFSET,
|
UNDEFINED_OFFSET,
|
||||||
@@ -493,7 +490,12 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
|||||||
for (i in 0 until expression.valueArgumentsCount) {
|
for (i in 0 until expression.valueArgumentsCount) {
|
||||||
putValueArgument(i, expression.getValueArgument(i))
|
putValueArgument(i, expression.getValueArgument(i))
|
||||||
}
|
}
|
||||||
putValueArgument(expression.valueArgumentsCount, getContinuationFromCaller())
|
val continuation = getContinuationFromCaller() ?: error(
|
||||||
|
"Cannot get continuation from context for a suspend call.\n" +
|
||||||
|
"Caller: ${ir2string(functionStack.peek())}\n" +
|
||||||
|
"Callee: ${ir2string(expression)}"
|
||||||
|
)
|
||||||
|
putValueArgument(expression.valueArgumentsCount, continuation)
|
||||||
}
|
}
|
||||||
return super.visitCall(res)
|
return super.visitCall(res)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user