diff --git a/tests/neg/i3542.scala b/tests/neg/i3542.scala new file mode 100644 index 000000000000..09b7437ad29c --- /dev/null +++ b/tests/neg/i3542.scala @@ -0,0 +1,8 @@ +object Test { + trait TC[A] + + implicit def case1[F[_]](implicit t: => TC[F[Any]]): TC[String] = ??? + implicit def case2[G[_]](implicit r: TC[G[Any]]): TC[Int] = ??? + + implicitly[TC[Int]] // error: no implicit argument of type TC[Int] found +} diff --git a/tests/pos/i3542-1.scala b/tests/pos/i3542-1.scala new file mode 100644 index 000000000000..6cdb6b2453fe --- /dev/null +++ b/tests/pos/i3542-1.scala @@ -0,0 +1,7 @@ +class Foo[T] + +object Test { + implicit def foo[T](implicit rec: => Foo[T]): Foo[T] = ??? + + val bla: Foo[Int] = implicitly[Foo[Int]] +} diff --git a/tests/pos/i3542-2.scala b/tests/pos/i3542-2.scala new file mode 100644 index 000000000000..90ece1ea2d78 --- /dev/null +++ b/tests/pos/i3542-2.scala @@ -0,0 +1,20 @@ +trait ::[H, T] + +trait Foo[A, R] + +trait FooLowPrio { + implicit def caseOther[A]: Foo[A, A :: Any] = null +} +object Foo extends FooLowPrio { + implicit def caseCons[H, HR, T, TR] + (implicit // It's a bit artificial: the by name is not required in this example... + t: => Foo[T, TR], + h: => Foo[H, HR] + ): Foo[H :: T, TR] = null + + implicit def caseAny: Foo[Any, Any] = null +} + +object Test { + val implicitFoo = implicitly[Foo[Long :: Any, Any]] +}