diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-08 16:05:05 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-08 16:05:05 -0700 |
commit | 72863241ead712ace45071a21b84288959f6ce53 (patch) | |
tree | 2dc6ad982cc7cac0955042f9da9cf59568ee81df /test/files/pos | |
parent | 9e064f783e7ee42b9d27655e2b15d830f8bae5f0 (diff) | |
parent | ede32ba3421be657a4369b847e60d5fb2b9def14 (diff) | |
download | scala-72863241ead712ace45071a21b84288959f6ce53.tar.gz scala-72863241ead712ace45071a21b84288959f6ce53.tar.bz2 scala-72863241ead712ace45071a21b84288959f6ce53.zip |
Merge pull request #2650 from paulp/issue/6221
SI-6221 inference with Function1 subtypes.
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/t6221.scala | 29 |
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 |