aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/neg/tailrec-2.scala
diff options
context:
space:
mode:
authorSamuel Gruetter <samuel.gruetter@epfl.ch>2014-03-12 22:44:33 +0100
committerSamuel Gruetter <samuel.gruetter@epfl.ch>2014-03-12 22:44:33 +0100
commit9ef5f6817688f814a3450126aa7383b0928e80a0 (patch)
tree5727a2f7f7fd665cefdb312af2785c692f04377c /tests/untried/neg/tailrec-2.scala
parent194be919664447631ba55446eb4874979c908d27 (diff)
downloaddotty-9ef5f6817688f814a3450126aa7383b0928e80a0.tar.gz
dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.tar.bz2
dotty-9ef5f6817688f814a3450126aa7383b0928e80a0.zip
add tests from scala/test/files/{pos,neg}
with explicit Unit return type
Diffstat (limited to 'tests/untried/neg/tailrec-2.scala')
-rw-r--r--tests/untried/neg/tailrec-2.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/untried/neg/tailrec-2.scala b/tests/untried/neg/tailrec-2.scala
new file mode 100644
index 000000000..d6b8b1355
--- /dev/null
+++ b/tests/untried/neg/tailrec-2.scala
@@ -0,0 +1,29 @@
+sealed abstract class Super[+A] {
+ def f[B >: A](mem: List[B]) : List[B]
+ def g(mem: List[_]) = ???
+}
+// 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)
+ @annotation.tailrec final def f1[B >: A](mem: List[B]): List[B] = this.g(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("")
+}