Skip to content

Commit b5f3bde

Browse files
authored
Merge pull request #3505 from dotty-staging/3452-test-cases
Add test cases from #3452
2 parents ecfc9ef + f218636 commit b5f3bde

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

tests/neg/i3542.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test {
2+
trait TC[A]
3+
4+
implicit def case1[F[_]](implicit t: => TC[F[Any]]): TC[String] = ???
5+
implicit def case2[G[_]](implicit r: TC[G[Any]]): TC[Int] = ???
6+
7+
implicitly[TC[Int]] // error: no implicit argument of type TC[Int] found
8+
}

tests/pos/i3542-1.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Foo[T]
2+
3+
object Test {
4+
implicit def foo[T](implicit rec: => Foo[T]): Foo[T] = ???
5+
6+
val bla: Foo[Int] = implicitly[Foo[Int]]
7+
}

tests/pos/i3542-2.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait ::[H, T]
2+
3+
trait Foo[A, R]
4+
5+
trait FooLowPrio {
6+
implicit def caseOther[A]: Foo[A, A :: Any] = null
7+
}
8+
object Foo extends FooLowPrio {
9+
implicit def caseCons[H, HR, T, TR]
10+
(implicit // It's a bit artificial: the by name is not required in this example...
11+
t: => Foo[T, TR],
12+
h: => Foo[H, HR]
13+
): Foo[H :: T, TR] = null
14+
15+
implicit def caseAny: Foo[Any, Any] = null
16+
}
17+
18+
object Test {
19+
val implicitFoo = implicitly[Foo[Long :: Any, Any]]
20+
}

0 commit comments

Comments
 (0)