diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index 6594b2be40a..d4d5f6ad414 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -127,6 +127,9 @@ public fun KtElement.getCall(context: BindingContext): Call? { val element = if (this is KtExpression) KtPsiUtil.deparenthesize(this) else this if (element == null) return null + // Do not use Call bound to outer call expression (if any) to prevent stack overflow during analysis + if (element is KtCallElement && element.calleeExpression == null) return null + val parent = element.getParent() val reference: KtExpression? = when { parent is KtInstanceExpressionWithLabel -> parent diff --git a/compiler/testData/cfg/bugs/kt10105.instructions b/compiler/testData/cfg/bugs/kt10105.instructions new file mode 100644 index 00000000000..bf1d6cd417c --- /dev/null +++ b/compiler/testData/cfg/bugs/kt10105.instructions @@ -0,0 +1,23 @@ +== foo == +fun foo() { + int x = ()() +} +--------------------- +L0: + 1 + 2 mark({ int x = ()() }) + magic[UNRESOLVED_CALL](int) -> + mark(= ()) + magic[UNRESOLVED_CALL](= ()) -> + mark(= ()()) + call(= ()(), |) -> + magic[VALUE_CONSUMER](= ()()|) -> + mark(int x = ()()) + call(int x = ()(), |) -> +L1: + 1 NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/bugs/kt10105.kt b/compiler/testData/cfg/bugs/kt10105.kt new file mode 100644 index 00000000000..d8b1ed68552 --- /dev/null +++ b/compiler/testData/cfg/bugs/kt10105.kt @@ -0,0 +1,3 @@ +fun foo() { + int x = ()() +} \ No newline at end of file diff --git a/compiler/testData/cfg/bugs/kt10105.values b/compiler/testData/cfg/bugs/kt10105.values new file mode 100644 index 00000000000..6c3e64efa24 --- /dev/null +++ b/compiler/testData/cfg/bugs/kt10105.values @@ -0,0 +1,12 @@ +== foo == +fun foo() { + int x = ()() +} +--------------------- + : * NEW: magic[VALUE_CONSUMER](= ()()|) -> +int : * NEW: magic[UNRESOLVED_CALL](int) -> += () : * NEW: magic[UNRESOLVED_CALL](= ()) -> += ()() : * NEW: call(= ()(), |) -> +int x = ()() : * NEW: call(int x = ()(), |) -> +{ int x = ()() } : * COPY +===================== diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java index 88696c07208..d5b16b9b813 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java @@ -145,6 +145,12 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { doTest(fileName); } + @TestMetadata("kt10105.kt") + public void testKt10105() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/kt10105.kt"); + doTest(fileName); + } + @TestMetadata("kt7761.kt") public void testKt7761() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/kt7761.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java index 86e54c9ec04..238df968b82 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java @@ -147,6 +147,12 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest { doTest(fileName); } + @TestMetadata("kt10105.kt") + public void testKt10105() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/kt10105.kt"); + doTest(fileName); + } + @TestMetadata("kt7761.kt") public void testKt7761() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/kt7761.kt");