From 815b7a27dfaea38882fc81a18c29016a7f2f2e38 Mon Sep 17 00:00:00 2001 From: Travis Brown Date: Sat, 30 Jan 2016 12:51:36 -0600 Subject: [PATCH] Add test for newly-supported type inference on syntax method --- core/src/test/scala/simulacrum/typeclass.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/test/scala/simulacrum/typeclass.scala b/core/src/test/scala/simulacrum/typeclass.scala index 4c7fc35..daf1503 100644 --- a/core/src/test/scala/simulacrum/typeclass.scala +++ b/core/src/test/scala/simulacrum/typeclass.scala @@ -303,6 +303,22 @@ class TypeClassTest extends WordSpec with Matchers { import Foo.ops._ Option(Option(1)).bar } + + "supports type inference for syntax for operations where the instance type is constrained" in { + @typeclass trait Ap[F[_]] { + def ap[A, B](ff: F[A => B])(fa: F[A]): F[B] + } + + object Ap { + implicit val apOption: Ap[Option] = new Ap[Option] { + def ap[A, B](ff: Option[A => B])(fa: Option[A]): Option[B] = ff.flatMap(fa.map) + } + } + + import Ap.ops._ + val ff: Option[Int => String] = Some(_.toString) + ff.ap(Some(0)) shouldBe Some("0") + } } "support annotated companions" in {