From cc3f450132d6c3fdba70524f1ee8bed09191ce1d Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 9 Dec 2013 20:24:47 +0400 Subject: [PATCH] added test for obsolete task #KT-2336 Fixed --- .../tests/nullabilityAndAutoCasts/kt2336.kt | 11 +++++++++++ .../jet/checkers/JetDiagnosticsTestGenerated.java | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt new file mode 100644 index 00000000000..6c7797e80be --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt @@ -0,0 +1,11 @@ +fun main(args: Array) { + val b: Boolean? = null + if (b != null) { + if (!b) {} // OK + if (b) {} // Error: Condition must be of type jet.Boolean, but is of type jet.Boolean? + if (b!!) {} // WARN: Unnecessary non-null assertion (!!) on a non-null receiver of type jet.Boolean? + foo(b) // OK + } +} + +fun foo(a: Boolean) = a \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index a149b2cc6f8..a4bd60fe6d3 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -4672,6 +4672,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt"); } + @TestMetadata("kt2336.kt") + public void testKt2336() throws Exception { + doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2336.kt"); + } + @TestMetadata("kt244.kt") public void testKt244() throws Exception { doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt");