diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt index 9a7c7a818ac..e7cd18c6456 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.debugger.evaluate.compilation import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.getCallLabelForLambdaArgument import org.jetbrains.kotlin.descriptors.* @@ -196,6 +197,9 @@ class CodeFragmentParameterAnalyzer( evaluationStatus.error(EvaluationError.SuspendCall) throw EvaluateExceptionUtil.createEvaluateException("Evaluation of 'suspend' calls is not supported") } + if (descriptor is ConstructorDescriptor && KotlinBuiltIns.isNothing(descriptor.returnType)) { + throw EvaluateExceptionUtil.createEvaluateException("'Nothing' can't be instantiated") + } } return super.visitCallExpression(expression, data) diff --git a/idea/jvm-debugger/jvm-debugger-test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinEvaluateExpressionTestGenerated.java b/idea/jvm-debugger/jvm-debugger-test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinEvaluateExpressionTestGenerated.java index 6e06bcd5417..53ca105f2df 100644 --- a/idea/jvm-debugger/jvm-debugger-test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/jvm-debugger/jvm-debugger-test/test/org/jetbrains/kotlin/idea/debugger/test/KotlinEvaluateExpressionTestGenerated.java @@ -345,6 +345,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nestedInlineArguments.kt"); } + @TestMetadata("nothing.kt") + public void testNothing() throws Exception { + runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.kt"); + } + @TestMetadata("onClassHeader.kt") public void testOnClassHeader() throws Exception { runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/onClassHeader.kt"); diff --git a/idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.kt b/idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.kt new file mode 100644 index 00000000000..743e53ff0fe --- /dev/null +++ b/idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.kt @@ -0,0 +1,28 @@ +package nothing + +fun main() { + //Breakpoint! + val a = 5 +} + +fun block(foo: () -> Unit) { + foo() +} + +// EXPRESSION: Nothing() +// RESULT: 'Nothing' can't be instantiated + +// EXPRESSION: "" + Nothing() +// RESULT: 'Nothing' can't be instantiated + +// EXPRESSION: run { Nothing() } +// RESULT: 'Nothing' can't be instantiated + +// EXPRESSION: { Nothing() } +// RESULT: 'Nothing' can't be instantiated + +// EXPRESSION: block { Nothing() } +// RESULT: 'Nothing' can't be instantiated + +// EXPRESSION: fun foo() { Nothing() } +// RESULT: 'Nothing' can't be instantiated \ No newline at end of file diff --git a/idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.out b/idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.out new file mode 100644 index 00000000000..dec71cf147c --- /dev/null +++ b/idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/nothing.out @@ -0,0 +1,7 @@ +LineBreakpoint created at nothing.kt:5 +Run Java +Connected to the target VM +nothing.kt:5 +Disconnected from the target VM + +Process finished with exit code 0