From 2a19016d58fcc48b6a1723415c5fd7bf47e1b912 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 25 Jul 2014 15:49:19 +0400 Subject: [PATCH] Pseudocode: Add test for parenthesized call in selector --- .../parenthesizedSelector.instructions | 88 +++++++++++++++++++ .../cfg/expressions/parenthesizedSelector.kt | 10 +++ .../expressions/parenthesizedSelector.values | 42 +++++++++ .../jet/cfg/ControlFlowTestGenerated.java | 5 ++ .../jet/cfg/PseudoValueTestGenerated.java | 5 ++ 5 files changed, 150 insertions(+) create mode 100644 compiler/testData/cfg/expressions/parenthesizedSelector.instructions create mode 100644 compiler/testData/cfg/expressions/parenthesizedSelector.kt create mode 100644 compiler/testData/cfg/expressions/parenthesizedSelector.values diff --git a/compiler/testData/cfg/expressions/parenthesizedSelector.instructions b/compiler/testData/cfg/expressions/parenthesizedSelector.instructions new file mode 100644 index 00000000000..728ed8fea38 --- /dev/null +++ b/compiler/testData/cfg/expressions/parenthesizedSelector.instructions @@ -0,0 +1,88 @@ +== with == +fun with(t: T, f : T.() -> Unit) { + t.f() +} +--------------------- +L0: + 1 + v(t: T) + magic[FAKE_INITIALIZER](t: T) -> + w(t|) + v(f : T.() -> Unit) + magic[FAKE_INITIALIZER](f : T.() -> Unit) -> + w(f|) + 2 mark({ t.f() }) + mark(t.f()) + r(f) -> + r(t) -> + mark(f()) + call(f(), invoke|, ) -> +L1: + 1 NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== foo == +val Int.foo: String.() -> Unit get() = {} +--------------------- +L0: + 1 + v(val Int.foo: String.() -> Unit get() = {}) +L1: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== bar == +fun bar() { + with(1) { + "".(foo)() + } +} +--------------------- +L0: + 1 + 2 mark({ with(1) { "".(foo)() } }) + r(1) -> + mark({ "".(foo)() }) + jmp?(L2) NEXT:[r({ "".(foo)() }) -> , d({ "".(foo)() })] + d({ "".(foo)() }) NEXT:[] +L2: + r({ "".(foo)() }) -> PREV:[jmp?(L2)] + mark(with(1) { "".(foo)() }) + call(with(1) { "".(foo)() }, with|, ) -> +L1: + 1 NEXT:[] +error: + PREV:[] +sink: + PREV:[, , d({ "".(foo)() })] +===================== +== anonymous_0 == +{ + "".(foo)() + } +--------------------- +L3: + 3 + 4 mark("".(foo)()) + mark("".(foo)()) + mark((foo)) + magic[IMPLICIT_RECEIVER](foo) -> + r(foo|) -> + mark("") + r("") -> + mark((foo)()) + call((foo)(), invoke|, ) -> + 3 ret(*|) L4 +L4: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/expressions/parenthesizedSelector.kt b/compiler/testData/cfg/expressions/parenthesizedSelector.kt new file mode 100644 index 00000000000..7c6d01e4ede --- /dev/null +++ b/compiler/testData/cfg/expressions/parenthesizedSelector.kt @@ -0,0 +1,10 @@ +fun with(t: T, f : T.() -> Unit) { + t.f() +} + +val Int.foo: String.() -> Unit get() = {} +fun bar() { + with(1) { + "".(foo)() + } +} \ No newline at end of file diff --git a/compiler/testData/cfg/expressions/parenthesizedSelector.values b/compiler/testData/cfg/expressions/parenthesizedSelector.values new file mode 100644 index 00000000000..63458d23c72 --- /dev/null +++ b/compiler/testData/cfg/expressions/parenthesizedSelector.values @@ -0,0 +1,42 @@ +== with == +fun with(t: T, f : T.() -> Unit) { + t.f() +} +--------------------- + : {<: T} NEW: magic[FAKE_INITIALIZER](t: T) -> + : {<: T.() -> Unit} NEW: magic[FAKE_INITIALIZER](f : T.() -> Unit) -> +t : {<: T} NEW: r(t) -> +f : {<: T.() -> Unit} NEW: r(f) -> +f() : * NEW: call(f(), invoke|, ) -> +t.f() : * COPY +{ t.f() } : * COPY +===================== +== foo == +val Int.foo: String.() -> Unit get() = {} +--------------------- +===================== +== bar == +fun bar() { + with(1) { + "".(foo)() + } +} +--------------------- +1 : Int NEW: r(1) -> +{ "".(foo)() } : {<: Int.() -> Unit} NEW: r({ "".(foo)() }) -> +with(1) { "".(foo)() } : * NEW: call(with(1) { "".(foo)() }, with|, ) -> +{ with(1) { "".(foo)() } } : * COPY +===================== +== anonymous_0 == +{ + "".(foo)() + } +--------------------- + : Int NEW: magic[IMPLICIT_RECEIVER](foo) -> +"" : String NEW: r("") -> +foo : {<: String.() -> Unit} NEW: r(foo|) -> +(foo) : {<: String.() -> Unit} COPY +(foo)() : Unit NEW: call((foo)(), invoke|, ) -> +"".(foo)() : Unit COPY +"".(foo)() : Unit COPY +===================== diff --git a/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java b/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java index 27b688b19e4..15bf6b4a93c 100644 --- a/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/cfg/ControlFlowTestGenerated.java @@ -409,6 +409,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { doTest("compiler/testData/cfg/expressions/nothingExpr.kt"); } + @TestMetadata("parenthesizedSelector.kt") + public void testParenthesizedSelector() throws Exception { + doTest("compiler/testData/cfg/expressions/parenthesizedSelector.kt"); + } + @TestMetadata("propertySafeCall.kt") public void testPropertySafeCall() throws Exception { doTest("compiler/testData/cfg/expressions/propertySafeCall.kt"); diff --git a/compiler/tests/org/jetbrains/jet/cfg/PseudoValueTestGenerated.java b/compiler/tests/org/jetbrains/jet/cfg/PseudoValueTestGenerated.java index 53a00c85775..533c9dd06f7 100644 --- a/compiler/tests/org/jetbrains/jet/cfg/PseudoValueTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/cfg/PseudoValueTestGenerated.java @@ -411,6 +411,11 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest { doTest("compiler/testData/cfg/expressions/nothingExpr.kt"); } + @TestMetadata("parenthesizedSelector.kt") + public void testParenthesizedSelector() throws Exception { + doTest("compiler/testData/cfg/expressions/parenthesizedSelector.kt"); + } + @TestMetadata("propertySafeCall.kt") public void testPropertySafeCall() throws Exception { doTest("compiler/testData/cfg/expressions/propertySafeCall.kt");