summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-05-02 13:21:06 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-05-02 16:18:35 +0200
commit49f50727944a478bc5d10ad0658437286f47e422 (patch)
treec4e7a931f24cccf3c371fca440ad94dd19efd371 /test/files/run
parent5819b78c25c9cba25fc84018d3905fe265bb4e18 (diff)
parent98972c95ab1e7c0ea2af9c9a958c0de60eb26b3d (diff)
downloadscala-49f50727944a478bc5d10ad0658437286f47e422.tar.gz
scala-49f50727944a478bc5d10ad0658437286f47e422.tar.bz2
scala-49f50727944a478bc5d10ad0658437286f47e422.zip
Merge 2.10.x into master
Conflicts: bincompat-forward.whitelist.conf src/compiler/scala/tools/nsc/matching/Patterns.scala src/compiler/scala/tools/nsc/transform/patmat/Logic.scala src/compiler/scala/tools/nsc/typechecker/Infer.scala src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala test/files/neg/t5663-badwarneq.check
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t7200.scala34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/files/run/t7200.scala b/test/files/run/t7200.scala
new file mode 100644
index 0000000000..ba342df14d
--- /dev/null
+++ b/test/files/run/t7200.scala
@@ -0,0 +1,34 @@
+import language.higherKinds
+
+object Test extends App {
+
+ // Slice of comonad is where this came up
+ trait Foo[F[_]] {
+ def coflatMap[A, B](f: F[A] => B): F[A] => F[B]
+ }
+
+ // A non-empty list
+ case class Nel[A](head: A, tail: List[A])
+
+ object NelFoo extends Foo[Nel] {
+
+ // It appears that the return type for recursive calls is not inferred
+ // properly, yet no warning is issued. Providing a return type or
+ // type arguments for the recursive call fixes the problem.
+
+ def coflatMap[A, B](f: Nel[A] => B) = // ok w/ return type
+ l => Nel(f(l), l.tail match {
+ case Nil => Nil
+ case h :: t => {
+ val r = coflatMap(f)(Nel(h, t)) // ok w/ type args
+ r.head :: r.tail
+ }
+ })
+ }
+
+ // Without a recursive call all is well, but with recursion we get a
+ // ClassCastException from Integer to Nothing
+ NelFoo.coflatMap[Int, Int](_.head + 1)(Nel(1, Nil)) // Ok
+ NelFoo.coflatMap[Int, Int](_.head + 1)(Nel(1, List(2))) // CCE
+
+}