Add extra tests for KT-20429, simplify code a bit

This commit is contained in:
Mikhail Glukhikh
2017-12-27 17:37:20 +03:00
parent a65304556c
commit 8e23ca597d
6 changed files with 93 additions and 5 deletions
@@ -1448,11 +1448,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
}
override fun visitInitializerList(list: KtInitializerList) {
list.initializers
.filterIsInstance<KtSuperTypeCallEntry>()
.forEach {
generateCallOrMarkUnresolved(it)
}
list.acceptChildren(this)
}
private fun generateCallOrMarkUnresolved(call: KtCallElement) {
@@ -0,0 +1,56 @@
== Test ==
enum class Test(f: () -> Unit) {
A(getFunc())
}
---------------------
L0:
1 <START>
v(f: () -> Unit)
magic[FAKE_INITIALIZER](f: () -> Unit) -> <v0>
w(f|<v0>)
v(A(getFunc()))
magic[FAKE_INITIALIZER](A(getFunc())) -> <v1>
w(A|<v1>)
mark(getFunc())
call(getFunc(), getFunc) -> <v2>
mark((getFunc()))
call((getFunc()), <init>|<v2>) -> <v3>
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== getFunc ==
fun getFunc(): () -> Unit = {}
---------------------
L0:
1 <START>
mark({})
jmp?(L2) NEXT:[r({}) -> <v0>, d({})]
d({}) NEXT:[<SINK>]
L2 [after local declaration]:
r({}) -> <v0> PREV:[jmp?(L2)]
ret(*|<v0>) L1
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>, d({})]
=====================
== anonymous_0 ==
{}
---------------------
L3:
2 <START>
3 mark()
read (Unit)
L4:
2 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,5 @@
enum class Test(f: () -> Unit) {
A(getFunc())
}
fun getFunc(): () -> Unit = {}
@@ -0,0 +1,19 @@
== Test ==
enum class Test(f: () -> Unit) {
A(getFunc())
}
---------------------
<v0>: {<: () -> Unit} NEW: magic[FAKE_INITIALIZER](f: () -> Unit) -> <v0>
<v1>: {<: Test} NEW: magic[FAKE_INITIALIZER](A(getFunc())) -> <v1>
getFunc() <v2>: {<: () -> Unit} NEW: call(getFunc(), getFunc) -> <v2>
(getFunc()) <v3>: * NEW: call((getFunc()), <init>|<v2>) -> <v3>
=====================
== getFunc ==
fun getFunc(): () -> Unit = {}
---------------------
{} <v0>: {<: () -> Unit} NEW: r({}) -> <v0>
=====================
== anonymous_0 ==
{}
---------------------
=====================
@@ -142,6 +142,12 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cfg/bugs"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("functionalCallInEnumEntry.kt")
public void testFunctionalCallInEnumEntry() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/functionalCallInEnumEntry.kt");
doTest(fileName);
}
@TestMetadata("jumpToOuterScope.kt")
public void testJumpToOuterScope() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/jumpToOuterScope.kt");
@@ -142,6 +142,12 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cfg/bugs"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("functionalCallInEnumEntry.kt")
public void testFunctionalCallInEnumEntry() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/functionalCallInEnumEntry.kt");
doTest(fileName);
}
@TestMetadata("jumpToOuterScope.kt")
public void testJumpToOuterScope() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cfg/bugs/jumpToOuterScope.kt");