From f34f7556bcb6cf3f1b6323b036590a76ca66e36d Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 30 Nov 2015 15:48:23 +0300 Subject: [PATCH] KT-10192 got fixed due to new if/when check (which doesn't depend on the expected type for expression) #KT-10192 Fixed --- .../diagnostics/testsWithStdLib/kt10192.kt | 20 +++++++++++++++++++ .../diagnostics/testsWithStdLib/kt10192.txt | 4 ++++ .../DiagnosticsTestWithStdLibGenerated.java | 6 ++++++ 3 files changed, 30 insertions(+) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/kt10192.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/kt10192.txt diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt10192.kt b/compiler/testData/diagnostics/testsWithStdLib/kt10192.kt new file mode 100644 index 00000000000..bb4ed7a89dd --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/kt10192.kt @@ -0,0 +1,20 @@ +fun test1() { + if (true) { + when (true) { + true -> println() + } + } else { + System.out?.println() // kotlin.Unit? + } +} + +fun test2() { + val mlist = arrayListOf("") + if (true) { + when (true) { + true -> println() + } + } else { + mlist.add("") // kotlin.Boolean + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt10192.txt b/compiler/testData/diagnostics/testsWithStdLib/kt10192.txt new file mode 100644 index 00000000000..69a8557802e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/kt10192.txt @@ -0,0 +1,4 @@ +package + +public fun test1(): kotlin.Unit +public fun test2(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index c47f1d35e21..9dd26e4d8b6 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -71,6 +71,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW doTest(fileName); } + @TestMetadata("kt10192.kt") + public void testKt10192() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/kt10192.kt"); + doTest(fileName); + } + @TestMetadata("kt9078.kt") public void testKt9078() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/kt9078.kt");