diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt index ed8a28a962f..add3bd1ddff 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/PatternMatchingTypingVisitor.kt @@ -179,7 +179,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping val entryExpression = whenEntry.expression ?: continue val entryTypeInfo = BindingContextUtils.getRecordedTypeInfo(entryExpression, bindingContext) ?: - throw AssertionError("When entry was not processed") + continue val entryType = entryTypeInfo.type val entryDataFlowInfo = diff --git a/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt b/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt new file mode 100644 index 00000000000..0aada5bcd69 --- /dev/null +++ b/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt @@ -0,0 +1,37 @@ +val test1 = when { + true -> { { true } } + else -> TODO() +} + +val test1a: () -> Boolean = when { + true -> { { true } } + else -> TODO() +} + +val test2 = when { + true -> { { true } } + else -> when { + true -> { { true } } + else -> TODO() + } +} + +val test2a: () -> Boolean = when { + true -> { { true } } + else -> when { + true -> { { true } } // TODO + else -> TODO() + } +} + +val test3 = when { + true -> { { true } } + true -> { { true } } + else -> TODO() +} + +val test3a: () -> Boolean = when { + true -> { { true } } + true -> { { true } } + else -> TODO() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.txt b/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.txt new file mode 100644 index 00000000000..75f0c0ce49b --- /dev/null +++ b/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.txt @@ -0,0 +1,8 @@ +package + +public val test1: kotlin.Nothing +public val test1a: () -> kotlin.Boolean +public val test2: kotlin.Nothing +public val test2a: () -> kotlin.Boolean +public val test3: kotlin.Nothing +public val test3a: () -> kotlin.Boolean diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index d3253f39674..c9b7752d224 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -18869,6 +18869,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt"); doTest(fileName); } + + @TestMetadata("whenWithNothingAndLambdas.kt") + public void testWhenWithNothingAndLambdas() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt"); + doTest(fileName); + } } }