diff --git a/compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt b/compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt new file mode 100644 index 00000000000..6396602a983 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt @@ -0,0 +1,11 @@ +interface A { + fun foo() +} + +fun takeA(a: A): Boolean = true + +fun test(a: Any) { + if (takeA(a as? A ?: return)) { + a.foo() + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/problems/noSmartcast.txt b/compiler/fir/resolve/testData/resolve/problems/noSmartcast.txt new file mode 100644 index 00000000000..fd0dffff06f --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/problems/noSmartcast.txt @@ -0,0 +1,24 @@ +FILE: noSmartcast.kt + public abstract interface A : R|kotlin/Any| { + public abstract fun foo(): R|kotlin/Unit| + + } + public final fun takeA(a: R|A|): R|kotlin/Boolean| { + ^takeA Boolean(true) + } + public final fun test(a: R|kotlin/Any|): R|kotlin/Unit| { + when () { + R|/takeA|(when (lval : R|A?| = (R|/a| as R|A?|)) { + ==($subj$, Null(null)) -> { + ^test Unit + } + else -> { + R|/| + } + } + ) -> { + R|/a|.R|/A.foo|() + } + } + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index ca918bb1938..122cf81180e 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -913,6 +913,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/problems/nestedClassContructor.kt"); } + @TestMetadata("noSmartcast.kt") + public void testNoSmartcast() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt"); + } + @TestMetadata("propertyFromJavaPlusAssign.kt") public void testPropertyFromJavaPlusAssign() throws Exception { runTest("compiler/fir/resolve/testData/resolve/problems/propertyFromJavaPlusAssign.kt");