diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.kt new file mode 100644 index 00000000000..1d63a3fb291 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.kt @@ -0,0 +1,18 @@ +// !WITH_NEW_INFERENCE + +class Data(val s: T) + +fun test_1(d: Data) { + if (d.s is String) { + d.s.length + } +} + +fun test_2(a: MutableList?) { + if (a != null) { + val b = a[0] // no SMARTCAST diagnostic + if (b != null) { + b.inc() + } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.txt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.txt new file mode 100644 index 00000000000..d8b56a60e39 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.txt @@ -0,0 +1,12 @@ +package + +public fun test_1(/*0*/ d: Data): kotlin.Unit +public fun test_2(/*0*/ a: kotlin.collections.MutableList?): kotlin.Unit + +public final class Data { + public constructor Data(/*0*/ s: T) + public final val s: 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 ca774ac6a73..7205d6b987d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -19776,6 +19776,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt"); } + @TestMetadata("kt25432.kt") + public void testKt25432() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.kt"); + } + @TestMetadata("kt2746.kt") public void testKt2746() throws Exception { runTest("compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 438e90d4afe..6559a239a09 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -19776,6 +19776,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt"); } + @TestMetadata("kt25432.kt") + public void testKt25432() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/inference/kt25432.kt"); + } + @TestMetadata("kt2746.kt") public void testKt2746() throws Exception { runTest("compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt");