aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/t2712-5.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-11 18:05:36 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-12 18:14:04 +0200
commitcdebd91712b36b048233d7cf9501cc7a5bb50b31 (patch)
tree35d3ee5d8800e958640916cd0145def1f5726751 /tests/pos/t2712-5.scala
parent1792c9e9bcff1feba7b50a24a46e1e20d8a39d9b (diff)
downloaddotty-cdebd91712b36b048233d7cf9501cc7a5bb50b31.tar.gz
dotty-cdebd91712b36b048233d7cf9501cc7a5bb50b31.tar.bz2
dotty-cdebd91712b36b048233d7cf9501cc7a5bb50b31.zip
Allow definition of new types in refinements
Allow definition of types in refinements that do not appear in parent type.
Diffstat (limited to 'tests/pos/t2712-5.scala')
-rw-r--r--tests/pos/t2712-5.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/pos/t2712-5.scala b/tests/pos/t2712-5.scala
new file mode 100644
index 000000000..ed96d4c06
--- /dev/null
+++ b/tests/pos/t2712-5.scala
@@ -0,0 +1,29 @@
+package test
+
+import scala.language.higherKinds
+
+trait Functor[F[_]] {
+ def map[A, B](f: A => B, fa: F[A]): F[B]
+}
+
+object Functor {
+ implicit def function[A]: Functor[({ type l[B] = A => B })#l] =
+ new Functor[({ type l[B] = A => B })#l] {
+ def map[C, B](cb: C => B, ac: A => C): A => B = cb compose ac
+ }
+}
+
+object FunctorSyntax {
+ implicit class FunctorOps[F[_], A](fa: F[A])(implicit F: Functor[F]) {
+ def map[B](f: A => B): F[B] = F.map(f, fa)
+ }
+}
+
+object Test {
+
+ val f: Int => String = _.toString
+
+ import FunctorSyntax._
+
+ f.map((s: String) => s.reverse)
+}