diff --git a/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt index bf130f8ce39..a719f6a369f 100644 --- a/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt +++ b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt @@ -538,7 +538,7 @@ class ControlFlowProcessor( createNonSyntheticValue(expression, MagicKind.UNRESOLVED_CALL, baseExpression) } - if (incrementOrDecrement) { + if (incrementOrDecrement && resolvedCall != null) { visitAssignment(baseExpression, getValueAsFunction(rhsValue), expression) if (expression is KtPostfixExpression) { copyValue(baseExpression, expression) @@ -1681,4 +1681,4 @@ class ControlFlowProcessor( return parameterValues } } -} \ No newline at end of file +} diff --git a/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions b/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions index 00e2c457590..d253f88b310 100644 --- a/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions +++ b/compiler/testData/cfg/arrays/arrayIncUnresolved.instructions @@ -26,11 +26,10 @@ L0: r(0) -> magic[UNRESOLVED_CALL](a[0]|, ) -> magic[UNRESOLVED_CALL](a[0]++|) -> - magic[UNRESOLVED_CALL](a[0]++|, ) -> L1: - 1 NEXT:[] + 1 NEXT:[] error: - PREV:[] + PREV:[] sink: - PREV:[, ] + PREV:[, ] ===================== diff --git a/compiler/testData/cfg/arrays/arrayIncUnresolved.values b/compiler/testData/cfg/arrays/arrayIncUnresolved.values index e384357f5f4..49fe78b0207 100644 --- a/compiler/testData/cfg/arrays/arrayIncUnresolved.values +++ b/compiler/testData/cfg/arrays/arrayIncUnresolved.values @@ -11,6 +11,6 @@ fun foo(a: A) { a : * NEW: r(a) -> 0 : * NEW: r(0) -> a[0] : * NEW: magic[UNRESOLVED_CALL](a[0]|, ) -> -a[0]++ : * COPY -{ a[0]++ } : * COPY -===================== \ No newline at end of file +a[0]++ : * NEW: magic[UNRESOLVED_CALL](a[0]++|) -> +{ a[0]++ } : * COPY +===================== diff --git a/compiler/testData/cfg/bugs/kt44153.instructions b/compiler/testData/cfg/bugs/kt44153.instructions new file mode 100644 index 00000000000..5f8375a1c23 --- /dev/null +++ b/compiler/testData/cfg/bugs/kt44153.instructions @@ -0,0 +1,73 @@ +== crash_1 == +fun crash_1() { + "".split(----------------------------------) +} +--------------------- +L0: + 1 + 2 mark({ "".split(----------------------------------) }) + mark("".split(----------------------------------)) + magic[UNRESOLVED_CALL](----|!) -> + magic[UNRESOLVED_CALL](------|) -> + magic[UNRESOLVED_CALL](--------|) -> + magic[UNRESOLVED_CALL](----------|) -> + magic[UNRESOLVED_CALL](------------|) -> + magic[UNRESOLVED_CALL](--------------|) -> + magic[UNRESOLVED_CALL](----------------|) -> + magic[UNRESOLVED_CALL](------------------|) -> + magic[UNRESOLVED_CALL](--------------------|) -> + magic[UNRESOLVED_CALL](----------------------|) -> + magic[UNRESOLVED_CALL](------------------------|) -> + magic[UNRESOLVED_CALL](--------------------------|) -> + magic[UNRESOLVED_CALL](----------------------------|) -> + magic[UNRESOLVED_CALL](------------------------------|) -> + magic[UNRESOLVED_CALL](--------------------------------|) -> + magic[UNRESOLVED_CALL](----------------------------------|) -> + mark("") + r("") -> + mark(split(----------------------------------)) + magic[UNRESOLVED_CALL](split(----------------------------------)|, !, ) -> +L1: + 1 NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== crash_2 == +fun crash_2() { + "".split(-----------------------------------) +} +--------------------- +L0: + 1 + 2 mark({ "".split(-----------------------------------) }) + mark("".split(-----------------------------------)) + magic[UNRESOLVED_CALL](---|!) -> + magic[UNRESOLVED_CALL](-----|) -> + magic[UNRESOLVED_CALL](-------|) -> + magic[UNRESOLVED_CALL](---------|) -> + magic[UNRESOLVED_CALL](-----------|) -> + magic[UNRESOLVED_CALL](-------------|) -> + magic[UNRESOLVED_CALL](---------------|) -> + magic[UNRESOLVED_CALL](-----------------|) -> + magic[UNRESOLVED_CALL](-------------------|) -> + magic[UNRESOLVED_CALL](---------------------|) -> + magic[UNRESOLVED_CALL](-----------------------|) -> + magic[UNRESOLVED_CALL](-------------------------|) -> + magic[UNRESOLVED_CALL](---------------------------|) -> + magic[UNRESOLVED_CALL](-----------------------------|) -> + magic[UNRESOLVED_CALL](-------------------------------|) -> + magic[UNRESOLVED_CALL](---------------------------------|) -> + magic[UNRESOLVED_CALL](-----------------------------------|) -> + mark("") + r("") -> + mark(split(-----------------------------------)) + magic[UNRESOLVED_CALL](split(-----------------------------------)|, !, ) -> +L1: + 1 NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/bugs/kt44153.kt b/compiler/testData/cfg/bugs/kt44153.kt new file mode 100644 index 00000000000..d07f79552a7 --- /dev/null +++ b/compiler/testData/cfg/bugs/kt44153.kt @@ -0,0 +1,9 @@ +// ISSUE: KT-44153 + +fun crash_1() { + "".split(----------------------------------) +} + +fun crash_2() { + "".split(-----------------------------------) +} diff --git a/compiler/testData/cfg/bugs/kt44153.values b/compiler/testData/cfg/bugs/kt44153.values new file mode 100644 index 00000000000..64af56d5946 --- /dev/null +++ b/compiler/testData/cfg/bugs/kt44153.values @@ -0,0 +1,57 @@ +== crash_1 == +fun crash_1() { + "".split(----------------------------------) +} +--------------------- +"" : * NEW: r("") -> +split !: * +-- !: * +---- : * NEW: magic[UNRESOLVED_CALL](----|!) -> +------ : * NEW: magic[UNRESOLVED_CALL](------|) -> +-------- : * NEW: magic[UNRESOLVED_CALL](--------|) -> +---------- : * NEW: magic[UNRESOLVED_CALL](----------|) -> +------------ : * NEW: magic[UNRESOLVED_CALL](------------|) -> +-------------- : * NEW: magic[UNRESOLVED_CALL](--------------|) -> +---------------- : * NEW: magic[UNRESOLVED_CALL](----------------|) -> +------------------ : * NEW: magic[UNRESOLVED_CALL](------------------|) -> +-------------------- : * NEW: magic[UNRESOLVED_CALL](--------------------|) -> +---------------------- : * NEW: magic[UNRESOLVED_CALL](----------------------|) -> +------------------------ : * NEW: magic[UNRESOLVED_CALL](------------------------|) -> +-------------------------- : * NEW: magic[UNRESOLVED_CALL](--------------------------|) -> +---------------------------- : * NEW: magic[UNRESOLVED_CALL](----------------------------|) -> +------------------------------ : * NEW: magic[UNRESOLVED_CALL](------------------------------|) -> +-------------------------------- : * NEW: magic[UNRESOLVED_CALL](--------------------------------|) -> +---------------------------------- : * NEW: magic[UNRESOLVED_CALL](----------------------------------|) -> +split(----------------------------------) : * NEW: magic[UNRESOLVED_CALL](split(----------------------------------)|, !, ) -> +"".split(----------------------------------) : * COPY +{ "".split(----------------------------------) } : * COPY +===================== +== crash_2 == +fun crash_2() { + "".split(-----------------------------------) +} +--------------------- +"" : * NEW: r("") -> +split !: * +- !: * +--- : * NEW: magic[UNRESOLVED_CALL](---|!) -> +----- : * NEW: magic[UNRESOLVED_CALL](-----|) -> +------- : * NEW: magic[UNRESOLVED_CALL](-------|) -> +--------- : * NEW: magic[UNRESOLVED_CALL](---------|) -> +----------- : * NEW: magic[UNRESOLVED_CALL](-----------|) -> +------------- : * NEW: magic[UNRESOLVED_CALL](-------------|) -> +--------------- : * NEW: magic[UNRESOLVED_CALL](---------------|) -> +----------------- : * NEW: magic[UNRESOLVED_CALL](-----------------|) -> +------------------- : * NEW: magic[UNRESOLVED_CALL](-------------------|) -> +--------------------- : * NEW: magic[UNRESOLVED_CALL](---------------------|) -> +----------------------- : * NEW: magic[UNRESOLVED_CALL](-----------------------|) -> +------------------------- : * NEW: magic[UNRESOLVED_CALL](-------------------------|) -> +--------------------------- : * NEW: magic[UNRESOLVED_CALL](---------------------------|) -> +----------------------------- : * NEW: magic[UNRESOLVED_CALL](-----------------------------|) -> +------------------------------- : * NEW: magic[UNRESOLVED_CALL](-------------------------------|) -> +--------------------------------- : * NEW: magic[UNRESOLVED_CALL](---------------------------------|) -> +----------------------------------- : * NEW: magic[UNRESOLVED_CALL](-----------------------------------|) -> +split(-----------------------------------) : * NEW: magic[UNRESOLVED_CALL](split(-----------------------------------)|, !, ) -> +"".split(-----------------------------------) : * COPY +{ "".split(-----------------------------------) } : * COPY +===================== diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt deleted file mode 100644 index c9ac93066a6..00000000000 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt +++ /dev/null @@ -1,9 +0,0 @@ -public fun foo() { - var i: Any = 1 - if (i is Int) { - while (i != 10) { - i++ // Here smart cast should not be performed due to a successor - i = "" - } - } -} diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.kt index 0a128a4bdb1..1c4cf751fec 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.kt @@ -1,9 +1,11 @@ +// FIR_IDENTICAL + public fun foo() { var i: Any = 1 if (i is Int) { while (i != 10) { - i++ // Here smart cast should not be performed due to a successor + i++ // Here smart cast should not be performed due to a successor i = "" } } -} \ No newline at end of file +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java index 9d5f94fa450..188960f8e7b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java @@ -154,6 +154,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { runTest("compiler/testData/cfg/bugs/kt37447.kt"); } + @TestMetadata("kt44153.kt") + public void testKt44153() throws Exception { + runTest("compiler/testData/cfg/bugs/kt44153.kt"); + } + @TestMetadata("kt7761.kt") public void testKt7761() throws Exception { runTest("compiler/testData/cfg/bugs/kt7761.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java index 467d96491ff..f7f3528e85c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java @@ -154,6 +154,11 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest { runTest("compiler/testData/cfg/bugs/kt37447.kt"); } + @TestMetadata("kt44153.kt") + public void testKt44153() throws Exception { + runTest("compiler/testData/cfg/bugs/kt44153.kt"); + } + @TestMetadata("kt7761.kt") public void testKt7761() throws Exception { runTest("compiler/testData/cfg/bugs/kt7761.kt");