diff --git a/compiler/testData/diagnostics/tests/when/kt4434.kt b/compiler/testData/diagnostics/tests/when/kt4434.kt new file mode 100644 index 00000000000..c103e1000ee --- /dev/null +++ b/compiler/testData/diagnostics/tests/when/kt4434.kt @@ -0,0 +1,27 @@ +// KT-4434 Missed diagnostic about else branch in when + +package test + +fun foo(): Int { + val a = "a" + return if (a.length() > 0) { + when (a) { + "a" -> 1 + } + } + else { + 3 + } +} + +fun bar(): Int { + val a = "a" + if (a.length() > 0) { + return when (a) { + "a" -> 1 + } + } + else { + return 3 + } +} diff --git a/compiler/testData/diagnostics/tests/when/kt4434.txt b/compiler/testData/diagnostics/tests/when/kt4434.txt new file mode 100644 index 00000000000..153c307f85b --- /dev/null +++ b/compiler/testData/diagnostics/tests/when/kt4434.txt @@ -0,0 +1,6 @@ +package + +package test { + internal fun bar(): kotlin.Int + internal fun foo(): kotlin.Int +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 6350c4816c4..0a2bd97d8ef 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -10635,6 +10635,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt4434.kt") + public void testKt4434() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/when/kt4434.kt"); + doTest(fileName); + } + @TestMetadata("NoElseExpectedUnit.kt") public void testNoElseExpectedUnit() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt");