aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/pos/t6221.scala
diff options
context:
space:
mode:
authorSamuel Gruetter <samuel.gruetter@epfl.ch>2014-03-12 22:44:33 +0100
committerSamuel Gruetter <samuel.gruetter@epfl.ch>2014-03-12 22:44:33 +0100
commit9ef5f6817688f814a3450126aa7383b0928e80a0 (patch)
tree5727a2f7f7fd665cefdb312af2785c692f04377c /tests/untried/pos/t6221.scala
parent194be919664447631ba55446eb4874979c908d27 (diff)
downloaddotty-9ef5f6817688f814a3450126aa7383b0928e80a0.tar.gz
dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.tar.bz2
dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.zip
add tests from scala/test/files/{pos,neg}
with explicit Unit return type
Diffstat (limited to 'tests/untried/pos/t6221.scala')
-rw-r--r--tests/untried/pos/t6221.scala33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/untried/pos/t6221.scala b/tests/untried/pos/t6221.scala
new file mode 100644
index 000000000..bb2f1dde7
--- /dev/null
+++ b/tests/untried/pos/t6221.scala
@@ -0,0 +1,33 @@
+class MyFunc[-A, +B] extends (A => B) { def apply(x: A): B = ??? }
+
+class MyCollection[A] {
+ def map[B](f: MyFunc[A, B]): MyCollection[B] = new MyCollection[B]
+}
+
+class OtherFunc[-A, +B] {}
+
+object Test {
+ implicit def functionToMyFunc[A, B](f: A => B): MyFunc[A, B] = new MyFunc // = new MyFunc[A,Nothing]();
+
+ implicit def otherFuncToMyFunc[A, B](f: OtherFunc[A, B]): MyFunc[A, B] = new MyFunc // = new MyFunc[A,Nothing]();
+
+ def main(args: Array[String]): Unit = {
+ val col = new MyCollection[Int]
+
+ // Doesn't compile: error: missing parameter type for expanded function ((x$1) => x$1.toString)
+ println(col.map(_.toString))
+ // scala.this.Predef.println(col.map[String](Test.this.functionToMyFunc[Int, String](((x$1: Int) => x$1.toString()))));
+
+ // Doesn't compile: error: missing parameter type
+ println(col.map(x => x.toString))
+ // scala.this.Predef.println(col.map[String](Test.this.functionToMyFunc[Int, String](((x: Int) => x.toString()))));
+
+ // Does compile
+ println(col.map((x: Int) => x.toString))
+ // scala.this.Predef.println(col.map[String](Test.this.functionToMyFunc[Int, String](((x: Int) => x.toString()))));
+
+ // Does compile (even though type params of OtherFunc not given)
+ println(col.map(new OtherFunc))
+ // scala.this.Predef.println(col.map[Nothing](Test.this.otherFuncToMyFunc[Any, Nothing](new OtherFunc[Any,Nothing]())))
+ }
+}