aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-17 22:32:10 +0200
committerMartin Odersky <odersky@gmail.com>2016-09-17 22:33:14 +0200
commit528f6b0524c465a3e795aa5bb538c680956bf6d2 (patch)
tree2a0f48e7f1ea2c9a52c15d0c9038712173804d41 /tests/neg
parentc420b4cc0573e88bf301d4e020e2ad91b26806d0 (diff)
downloaddotty-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/neg')
-rw-r--r--tests/neg/i1503.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/neg/i1503.scala b/tests/neg/i1503.scala
new file mode 100644
index 000000000..8e5dc53c6
--- /dev/null
+++ b/tests/neg/i1503.scala
@@ -0,0 +1,14 @@
+object Test {
+
+ val cond = true
+ def foo1() = println("hi")
+ def bar1() = println("there")
+
+ def foo2(x: Int) = println("hi")
+ def bar2(x: Int) = println("there")
+
+ def main(args: Array[String]) = {
+ (if (cond) foo1 else bar1)() // error: Unit does not take parameters
+ (if (cond) foo2 else bar2)(22) // error: missing arguments // error: missing arguments
+ }
+}