Debugger: Prohibit 'suspend fun' calls in evaluated expressions

Currently, it's impossible to call suspend functions in evaluated code fragments (see KT-31701).
This commit officially prohibits such calls, so users will see a semi-friendly error message.
This commit is contained in:
Yan Zhulanow
2019-07-09 22:24:20 +09:00
parent 910133dbfb
commit d6487e89ad
4 changed files with 35 additions and 0 deletions
@@ -184,6 +184,18 @@ class CodeFragmentParameterAnalyzer(
return null
}
override fun visitCallExpression(expression: KtCallExpression, data: Unit?): Void? {
val resolvedCall = expression.getResolvedCall(bindingContext)
if (resolvedCall != null) {
val descriptor = resolvedCall.resultingDescriptor
if (descriptor is FunctionDescriptor && descriptor.isSuspend) {
throw EvaluateExceptionUtil.createEvaluateException("Evaluation of 'suspend' calls is not supported")
}
}
return super.visitCallExpression(expression, data)
}
}, Unit)
return CodeFragmentParameterInfo(parameters.values.toList(), crossingBounds)