diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-17 22:32:10 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-09-17 22:33:14 +0200 |
commit | 528f6b0524c465a3e795aa5bb538c680956bf6d2 (patch) | |
tree | 2a0f48e7f1ea2c9a52c15d0c9038712173804d41 /tests/run/i1503.scala | |
parent | c420b4cc0573e88bf301d4e020e2ad91b26806d0 (diff) | |
download | dotty-528f6b0524c465a3e795aa5bb538c680956bf6d2.tar.gz dotty-528f6b0524c465a3e795aa5bb538c680956bf6d2.tar.bz2 dotty-528f6b0524c465a3e795aa5bb538c680956bf6d2.zip |
Fix #1503 - be careful where to insert an apply.
`apply` nodes should not be inserted in the result parts
of a block, if-then-else, match, or try. Instead they should
be added to the surrounding statement.
Diffstat (limited to 'tests/run/i1503.scala')
-rw-r--r-- | tests/run/i1503.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/run/i1503.scala b/tests/run/i1503.scala new file mode 100644 index 000000000..56bb9af0c --- /dev/null +++ b/tests/run/i1503.scala @@ -0,0 +1,38 @@ +object Test { + + def test1() = + (new Function0[Unit] { + def apply() = println("hello") + })() + + val cond = true + val foo = () => println("hi") + val bar = () => println("there") + + val baz = (x: Int) => println(x) + + def test2() = + (if (cond) foo else bar)() + + def test2a() = + (if (cond) baz else baz)(33) + + def test3() = + (try foo + catch { case ex: Exception => bar } + finally ())() + + def test4() = + (cond match { + case true => foo + case false => bar + })() + + def main(args: Array[String]) = { + test1() + test2() + test2a() + test3() + test4() + } +} |