diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.dot b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.dot new file mode 100644 index 00000000000..dce6fd6fa8b --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.dot @@ -0,0 +1,138 @@ +digraph smartcastFromArgument_kt { + graph [splines=ortho nodesep=3] + node [shape=box penwidth=2] + edge [penwidth=2] + + subgraph cluster_0 { + color=red + 0 [label="Enter function foo" style="filled" fillcolor=red]; + 1 [label="Exit function foo" style="filled" fillcolor=red]; + } + + 0 -> {1}; + + subgraph cluster_1 { + color=red + 2 [label="Enter function takeA" style="filled" fillcolor=red]; + 3 [label="Const: Boolean(true)"]; + 4 [label="Jump: ^takeA Boolean(true)"]; + 5 [label="Stub" style="filled" fillcolor=gray]; + 6 [label="Exit function takeA" style="filled" fillcolor=red]; + } + + 2 -> {3}; + 3 -> {4}; + 4 -> {6}; + 4 -> {5} [style=dotted]; + 5 -> {6} [style=dotted]; + + subgraph cluster_2 { + color=red + 7 [label="Enter function test" style="filled" fillcolor=red]; + subgraph cluster_3 { + color=blue + 8 [label="Enter when"]; + subgraph cluster_4 { + color=blue + 9 [label="Enter when branch condition "]; + subgraph cluster_5 { + color=blue + 10 [label="Enter when"]; + 11 [label="Access variable R|/a|"]; + 12 [label="Type operator: a as? A"]; + 13 [label="Variable declaration: lval : R|A?|"]; + subgraph cluster_6 { + color=blue + 14 [label="Enter when branch condition "]; + 15 [label="Const: Null(null)"]; + 16 [label="Operator =="]; + 17 [label="Exit when branch condition"]; + } + subgraph cluster_7 { + color=blue + 18 [label="Enter when branch condition else"]; + 19 [label="Exit when branch condition"]; + } + 20 [label="Enter when branch result"]; + subgraph cluster_8 { + color=blue + 21 [label="Enter block"]; + 22 [label="Access variable R|/|"]; + 23 [label="Exit block"]; + } + 24 [label="Exit when branch result"]; + 25 [label="Enter when branch result"]; + subgraph cluster_9 { + color=blue + 26 [label="Enter block"]; + 27 [label="Jump: ^test Unit"]; + 28 [label="Stub" style="filled" fillcolor=gray]; + 29 [label="Exit block" style="filled" fillcolor=gray]; + } + 30 [label="Exit when branch result" style="filled" fillcolor=gray]; + 31 [label="Exit when"]; + } + 32 [label="Function call: R|/takeA|(when (lval : R|A?| = (R|/a| as? R|A|)) { + ==($subj$, Null(null)) -> { + ^test Unit + } + else -> { + R|/| + } +} +)"]; + 33 [label="Exit when branch condition"]; + } + 34 [label="Synthetic else branch"]; + 35 [label="Enter when branch result"]; + subgraph cluster_10 { + color=blue + 36 [label="Enter block"]; + 37 [label="Access variable R|/a|"]; + 38 [label="Function call: R|/a|.R|/A.foo|()"]; + 39 [label="Exit block"]; + } + 40 [label="Exit when branch result"]; + 41 [label="Exit when"]; + } + 42 [label="Exit function test" style="filled" fillcolor=red]; + } + + 7 -> {8}; + 8 -> {9}; + 9 -> {10}; + 10 -> {11}; + 11 -> {12}; + 12 -> {13}; + 13 -> {14}; + 14 -> {15}; + 15 -> {16}; + 16 -> {17}; + 17 -> {25 18}; + 18 -> {19}; + 19 -> {20}; + 20 -> {21}; + 21 -> {22}; + 22 -> {23}; + 23 -> {24}; + 24 -> {31}; + 25 -> {26}; + 26 -> {27}; + 27 -> {42}; + 27 -> {28} [style=dotted]; + 28 -> {29} [style=dotted]; + 29 -> {30} [style=dotted]; + 30 -> {31} [style=dotted]; + 31 -> {32}; + 32 -> {33}; + 33 -> {35 34}; + 34 -> {41}; + 35 -> {36}; + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {42}; + +} diff --git a/compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.kt similarity index 74% rename from compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt rename to compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.kt index 6396602a983..fb74156ae80 100644 --- a/compiler/fir/resolve/testData/resolve/problems/noSmartcast.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.kt @@ -6,6 +6,6 @@ fun takeA(a: A): Boolean = true fun test(a: Any) { if (takeA(a as? A ?: return)) { - a.foo() + 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/smartcasts/smartcastFromArgument.txt similarity index 88% rename from compiler/fir/resolve/testData/resolve/problems/noSmartcast.txt rename to compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.txt index a46a2637e2a..3431aafca16 100644 --- a/compiler/fir/resolve/testData/resolve/problems/noSmartcast.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.txt @@ -1,4 +1,4 @@ -FILE: noSmartcast.kt +FILE: smartcastFromArgument.kt public abstract interface A : R|kotlin/Any| { public abstract fun foo(): R|kotlin/Unit| @@ -17,7 +17,7 @@ FILE: noSmartcast.kt } } ) -> { - R|/a|.#() + 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 5088ebc3924..bd9cc52d3a3 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1041,11 +1041,6 @@ 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"); diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java index 4001275e2d8..609082e7bcb 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithCfgTestGenerated.java @@ -218,6 +218,11 @@ public class FirDiagnosticsWithCfgTestGenerated extends AbstractFirDiagnosticsWi runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartcastAfterReassignment.kt"); } + @TestMetadata("smartcastFromArgument.kt") + public void testSmartcastFromArgument() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartcastFromArgument.kt"); + } + @TestMetadata("smartcastOnLambda.kt") public void testSmartcastOnLambda() throws Exception { runTest("compiler/fir/resolve/testData/resolve/smartcasts/smartcastOnLambda.kt"); diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 84b3f73d33d..f2dcd9bebf8 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1041,11 +1041,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos 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");