diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt index 78f0d1f9ef0..5e3469d4965 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt @@ -1448,11 +1448,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) { } override fun visitInitializerList(list: KtInitializerList) { - list.initializers - .filterIsInstance() - .forEach { - generateCallOrMarkUnresolved(it) - } + list.acceptChildren(this) } private fun generateCallOrMarkUnresolved(call: KtCallElement) { diff --git a/compiler/testData/cfg/bugs/functionalCallInEnumEntry.instructions b/compiler/testData/cfg/bugs/functionalCallInEnumEntry.instructions new file mode 100644 index 00000000000..d63352ea685 --- /dev/null +++ b/compiler/testData/cfg/bugs/functionalCallInEnumEntry.instructions @@ -0,0 +1,56 @@ +== Test == +enum class Test(f: () -> Unit) { + A(getFunc()) +} +--------------------- +L0: + 1 + v(f: () -> Unit) + magic[FAKE_INITIALIZER](f: () -> Unit) -> + w(f|) + v(A(getFunc())) + magic[FAKE_INITIALIZER](A(getFunc())) -> + w(A|) + mark(getFunc()) + call(getFunc(), getFunc) -> + mark((getFunc())) + call((getFunc()), |) -> +L1: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== getFunc == +fun getFunc(): () -> Unit = {} +--------------------- +L0: + 1 + mark({}) + jmp?(L2) NEXT:[r({}) -> , d({})] + d({}) NEXT:[] +L2 [after local declaration]: + r({}) -> PREV:[jmp?(L2)] + ret(*|) L1 +L1: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, , d({})] +===================== +== anonymous_0 == +{} +--------------------- +L3: + 2 + 3 mark() + read (Unit) +L4: + 2 NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/bugs/functionalCallInEnumEntry.kt b/compiler/testData/cfg/bugs/functionalCallInEnumEntry.kt new file mode 100644 index 00000000000..465016c5501 --- /dev/null +++ b/compiler/testData/cfg/bugs/functionalCallInEnumEntry.kt @@ -0,0 +1,5 @@ +enum class Test(f: () -> Unit) { + A(getFunc()) +} + +fun getFunc(): () -> Unit = {} \ No newline at end of file diff --git a/compiler/testData/cfg/bugs/functionalCallInEnumEntry.values b/compiler/testData/cfg/bugs/functionalCallInEnumEntry.values new file mode 100644 index 00000000000..be077902944 --- /dev/null +++ b/compiler/testData/cfg/bugs/functionalCallInEnumEntry.values @@ -0,0 +1,19 @@ +== Test == +enum class Test(f: () -> Unit) { + A(getFunc()) +} +--------------------- + : {<: () -> Unit} NEW: magic[FAKE_INITIALIZER](f: () -> Unit) -> + : {<: Test} NEW: magic[FAKE_INITIALIZER](A(getFunc())) -> +getFunc() : {<: () -> Unit} NEW: call(getFunc(), getFunc) -> +(getFunc()) : * NEW: call((getFunc()), |) -> +===================== +== getFunc == +fun getFunc(): () -> Unit = {} +--------------------- +{} : {<: () -> Unit} NEW: r({}) -> +===================== +== anonymous_0 == +{} +--------------------- +===================== diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java index f08ef47454d..63ce876c859 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java @@ -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"); diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java index 1e0a3a7086d..458ea44b6ff 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java @@ -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");