aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/function-arity.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-10-31 12:58:01 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-16 15:23:43 +0100
commit29104c9755a9d6393959a416650422b84f0957f2 (patch)
tree19f844e71f9904c19714f4cab8c93fffc97db437 /tests/pos/function-arity.scala
parent5e8023335e641c9c05c6517a82764571e7ef6386 (diff)
downloaddotty-29104c9755a9d6393959a416650422b84f0957f2.tar.gz
dotty-29104c9755a9d6393959a416650422b84f0957f2.tar.bz2
dotty-29104c9755a9d6393959a416650422b84f0957f2.zip
Auto-uncurry n-ary functions.
Implements SIP #897.
Diffstat (limited to 'tests/pos/function-arity.scala')
-rw-r--r--tests/pos/function-arity.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/pos/function-arity.scala b/tests/pos/function-arity.scala
new file mode 100644
index 000000000..bb1a1cb8e
--- /dev/null
+++ b/tests/pos/function-arity.scala
@@ -0,0 +1,18 @@
+object Test {
+ def call(k: (Int, Int) => Unit): Unit = ???
+ def test = call({ case (x, y) => ()})
+
+ trait X extends Function1[Int, String]
+ implicit def f2x(f: Function1[Int, String]): X = ???
+ ({case _ if "".isEmpty => ""} : X) // allowed, implicit view used to adapt
+
+ // ({case _ if "".isEmpty => 0} : X) // expected String, found Int
+
+ def unary[T](a: T, b: T, f: ((T, T)) => T): T = f((a, b))
+ unary(1, 2, (x, y) => x)
+ unary(1, 2, (x: Int, y) => x)
+ unary(1, 2, (x: Int, y: Float) => x)
+
+ val xs = List(1, 2, 3)
+ xs.zipWithIndex.map(_ + _)
+}