diff options
author | Paul Phillips <paulp@improving.org> | 2010-07-02 04:20:44 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-07-02 04:20:44 +0000 |
commit | fbc453397552983a2c2a229cca8f7c13a641b9c7 (patch) | |
tree | ed5101b5693e52f7e8160e3bc7b38ed70ddf3892 /test/files/neg/tailrec-2.scala | |
parent | 58adc8d999687d1cfa6394d7f4201dfaf411ccfe (diff) | |
download | scala-fbc453397552983a2c2a229cca8f7c13a641b9c7.tar.gz scala-fbc453397552983a2c2a229cca8f7c13a641b9c7.tar.bz2 scala-fbc453397552983a2c2a229cca8f7c13a641b9c7.zip |
Some more improvement on the error messages whe...
Some more improvement on the error messages when @tailrec fails. Now it
gives a sensible message if the recursive target is actually a supertype
of this, rather than saying the call is not in tail position. No review.
Diffstat (limited to 'test/files/neg/tailrec-2.scala')
-rw-r--r-- | test/files/neg/tailrec-2.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/neg/tailrec-2.scala b/test/files/neg/tailrec-2.scala new file mode 100644 index 0000000000..4388815a06 --- /dev/null +++ b/test/files/neg/tailrec-2.scala @@ -0,0 +1,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] = error("") +} + +object Bop { + def m1[A] : Super[A] = error("") + def m2[A] : Bop2[A] = error("") +}
\ No newline at end of file |