From 221501c0d946766a0c46a1ba60805c65e5b4758a Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 7 Apr 2015 18:44:29 +0300 Subject: [PATCH] Tests for KT-2865. Passes already in M11 or even earlier --- .../diagnostics/tests/smartCasts/varnotnull/kt2865.kt | 11 +++++++++++ .../tests/smartCasts/varnotnull/kt2865.txt | 5 +++++ .../kotlin/checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ 3 files changed, 22 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.txt diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.kt new file mode 100644 index 00000000000..44190e099e4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.kt @@ -0,0 +1,11 @@ +fun MutableMap.set(k: K, v: V) {} + +fun foo(a: MutableMap, x: String?) { + a[x!!] = x + a[x] = x!! +} + +fun foo1(a: MutableMap, x: String?) { + a[x] = x!! + a[x!!] = x +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.txt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.txt new file mode 100644 index 00000000000..d73971438fd --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.txt @@ -0,0 +1,5 @@ +package + +internal fun foo(/*0*/ a: kotlin.MutableMap, /*1*/ x: kotlin.String?): kotlin.Unit +internal fun foo1(/*0*/ a: kotlin.MutableMap, /*1*/ x: kotlin.String?): kotlin.Unit +internal fun kotlin.MutableMap.set(/*0*/ k: K, /*1*/ v: V): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 45766b98a54..2fcc46f0e40 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -11323,6 +11323,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/varnotnull"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("kt2865.kt") + public void testKt2865() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt2865.kt"); + doTest(fileName); + } + @TestMetadata("kt3224.kt") public void testKt3224() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/kt3224.kt");