diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-06-25 09:45:27 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-07-13 15:31:16 +0200 |
commit | ef536f00d9d480f28db3093b9dc09a90041cfb74 (patch) | |
tree | ca82afa7a37ce866978b0b66904941672f2dacc3 /tests/run/t7200.scala | |
parent | 9185428b63b138f8c05ade5592e59956296b5128 (diff) | |
download | dotty-ef536f00d9d480f28db3093b9dc09a90041cfb74.tar.gz dotty-ef536f00d9d480f28db3093b9dc09a90041cfb74.tar.bz2 dotty-ef536f00d9d480f28db3093b9dc09a90041cfb74.zip |
Enable 61 tests that succeed.
Diffstat (limited to 'tests/run/t7200.scala')
-rw-r--r-- | tests/run/t7200.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/run/t7200.scala b/tests/run/t7200.scala new file mode 100644 index 000000000..8f33d016f --- /dev/null +++ b/tests/run/t7200.scala @@ -0,0 +1,34 @@ +import language.higherKinds + +object Test extends dotty.runtime.LegacyApp { + + // 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 + +} |