summaryrefslogtreecommitdiff
path: root/test/files/pos/t6221.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-06-12 04:50:00 -0400
committerPaul Phillips <paulp@improving.org>2013-06-13 08:49:21 -0400
commitede32ba3421be657a4369b847e60d5fb2b9def14 (patch)
tree27245ef1a38020a173e9a816f5087246ffa63ddb /test/files/pos/t6221.scala
parentf790662a3eab1e8efce5d4096d0efbae96cf45b4 (diff)
downloadscala-ede32ba3421be657a4369b847e60d5fb2b9def14.tar.gz
scala-ede32ba3421be657a4369b847e60d5fb2b9def14.tar.bz2
scala-ede32ba3421be657a4369b847e60d5fb2b9def14.zip
SI-6221 inference with Function1 subtypes.
There appears to be no upper bound on the number of places we have to remove calls to typeSymbol and introduce calls to baseType. This one was type inference for function parameter types: worked when expected type was A => B, but not if there was an implicit conversion from A => B to the expected type.
Diffstat (limited to 'test/files/pos/t6221.scala')
-rw-r--r--test/files/pos/t6221.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/files/pos/t6221.scala b/test/files/pos/t6221.scala
new file mode 100644
index 0000000000..dd7776f596
--- /dev/null
+++ b/test/files/pos/t6221.scala
@@ -0,0 +1,29 @@
+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
+
+ implicit def otherFuncToMyFunc[A, B](f: OtherFunc[A, B]): MyFunc[A, B] = new MyFunc
+
+ def main(args: Array[String]) {
+ val col = new MyCollection[Int]
+
+ // Doesn't compile: error: missing parameter type for expanded function ((x$1) => x$1.toString)
+ println(col.map(_.toString))
+
+ // Doesn't compile: error: missing parameter type
+ println(col.map(x => x.toString))
+
+ // Does compile
+ println(col.map((x: Int) => x.toString))
+
+ // Does compile (even though type params of OtherFunc not given)
+ println(col.map(new OtherFunc))
+ }
+} \ No newline at end of file