blob: 342cd85323b5d8b5a3f7d1a108a821cf4007f778 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
sealed abstract class Super[+A] {
def f[B >: A](mem: List[B]) : List[B]
}
// This one should fail, target is a supertype
class Bop1[+A](val element: A) extends Super[A] {
@annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem)
}
// These succeed
class Bop2[+A](val element: A) extends Super[A] {
@annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Bop2[A]).f(mem)
}
object Bop3 extends Super[Nothing] {
@annotation.tailrec final def f[B](mem: List[B]): List[B] = (null: Bop3.type).f(mem)
}
class Bop4[+A](val element: A) extends Super[A] {
@annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = Other.f[A].f(mem)
}
object Other {
def f[T] : Bop4[T] = sys.error("")
}
object Bop {
def m1[A] : Super[A] = sys.error("")
def m2[A] : Bop2[A] = sys.error("")
}
|