Misc: Do not use resolved call of outer expression if current call expression has no callee

#KT-10105 Fixed
This commit is contained in:
Alexey Sedunov
2015-11-20 16:15:58 +03:00
parent a01a18cb1a
commit b75665a96a
6 changed files with 53 additions and 0 deletions
@@ -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
+23
View File
@@ -0,0 +1,23 @@
== foo ==
fun foo() {
int x = ()()
}
---------------------
L0:
1 <START>
2 mark({ int x = ()() })
magic[UNRESOLVED_CALL](int) -> <v0>
mark(= ())
magic[UNRESOLVED_CALL](= ()) -> <v1>
mark(= ()())
call(= ()(), <ERROR FUNCTION>|<v1>) -> <v2>
magic[VALUE_CONSUMER](= ()()|<v2>) -> <v3>
mark(int x = ()())
call(int x = ()(), <ERROR FUNCTION>|<v0>) -> <v4>
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
+3
View File
@@ -0,0 +1,3 @@
fun foo() {
int x = ()()
}
+12
View File
@@ -0,0 +1,12 @@
== foo ==
fun foo() {
int x = ()()
}
---------------------
<v3>: * NEW: magic[VALUE_CONSUMER](= ()()|<v2>) -> <v3>
int <v0>: * NEW: magic[UNRESOLVED_CALL](int) -> <v0>
= () <v1>: * NEW: magic[UNRESOLVED_CALL](= ()) -> <v1>
= ()() <v2>: * NEW: call(= ()(), <ERROR FUNCTION>|<v1>) -> <v2>
int x = ()() <v4>: * NEW: call(int x = ()(), <ERROR FUNCTION>|<v0>) -> <v4>
{ int x = ()() } <v4>: * COPY
=====================
@@ -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");
@@ -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");