From 7ac55cefcb4980f7ef8adc85b80884e896ee3eee Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jan 2016 16:42:58 +0300 Subject: [PATCH] Extra test with smart cast to 'T' --- .../testData/codegen/box/smartCasts/genericSet.kt | 13 +++++++++++++ .../diagnostics/tests/smartCasts/genericSet.kt | 7 +++++++ .../diagnostics/tests/smartCasts/genericSet.txt | 11 +++++++++++ .../kotlin/checkers/DiagnosticsTestGenerated.java | 6 ++++++ .../generated/BlackBoxCodegenTestGenerated.java | 6 ++++++ 5 files changed, 43 insertions(+) create mode 100644 compiler/testData/codegen/box/smartCasts/genericSet.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/genericSet.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/genericSet.txt diff --git a/compiler/testData/codegen/box/smartCasts/genericSet.kt b/compiler/testData/codegen/box/smartCasts/genericSet.kt new file mode 100644 index 00000000000..48350f84309 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/genericSet.kt @@ -0,0 +1,13 @@ +class Wrapper(var x: T) + +inline fun change(w: Wrapper, x: Any?) { + if (x is T) { + w.x = x + } +} + +fun box(): String { + val w = Wrapper("FAIL") + change(w, "OK") + return w.x +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/genericSet.kt b/compiler/testData/diagnostics/tests/smartCasts/genericSet.kt new file mode 100644 index 00000000000..199993d030a --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/genericSet.kt @@ -0,0 +1,7 @@ +class Wrapper(var x: T) + +inline fun change(w: Wrapper, x: Any?) { + if (x is T) { + w.x = x + } +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/genericSet.txt b/compiler/testData/diagnostics/tests/smartCasts/genericSet.txt new file mode 100644 index 00000000000..56403fba29b --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/genericSet.txt @@ -0,0 +1,11 @@ +package + +public inline fun change(/*0*/ w: Wrapper, /*1*/ x: kotlin.Any?): kotlin.Unit + +public final class Wrapper { + public constructor Wrapper(/*0*/ x: T) + public final var x: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 0e9ed2351df..ac03b8865e9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -15615,6 +15615,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("genericSet.kt") + public void testGenericSet() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/genericSet.kt"); + doTest(fileName); + } + @TestMetadata("ifCascadeExprNotNull.kt") public void testIfCascadeExprNotNull() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/ifCascadeExprNotNull.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 571cd0b2a09..fc227d48ece 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -7357,6 +7357,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("genericSet.kt") + public void testGenericSet() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/genericSet.kt"); + doTest(fileName); + } + @TestMetadata("implicitExtensionReceiver.kt") public void testImplicitExtensionReceiver() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/implicitExtensionReceiver.kt");