diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-05-31 23:49:52 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-07-10 10:44:20 +1000 |
commit | a90d1f01d603d9f00445ead48a87a051cd0ede15 (patch) | |
tree | acd71415af0d2a487ad7fa7b31afaa2fafe4fddd /test/files/pos | |
parent | 07fc7bb2f718f335058ea84700778827747a6314 (diff) | |
download | scala-a90d1f01d603d9f00445ead48a87a051cd0ede15.tar.gz scala-a90d1f01d603d9f00445ead48a87a051cd0ede15.tar.bz2 scala-a90d1f01d603d9f00445ead48a87a051cd0ede15.zip |
SI-6574 Support @tailrec for extension methods.
Currently, when the body of an extension method is transplanted
to the companion object, recursive calls point back to the original
instance method. That changes during erasure, but this is too late
for tail call analysis/elimination.
This commit eagerly updates the recursive calls to point to the
extension method in the companion. It also removes the @tailrec
annotation from the original method.
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/t6574.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/pos/t6574.scala b/test/files/pos/t6574.scala new file mode 100644 index 0000000000..59c1701eb4 --- /dev/null +++ b/test/files/pos/t6574.scala @@ -0,0 +1,19 @@ +class Bad[X, Y](val v: Int) extends AnyVal { + def vv = v + @annotation.tailrec final def foo[Z](a: Int)(b: String) { + this.foo[Z](a)(b) + } + + @annotation.tailrec final def differentReceiver { + {(); new Bad[X, Y](0)}.differentReceiver + } + + @annotation.tailrec final def dependent[Z](a: Int)(b: String): b.type = { + this.dependent[Z](a)(b) + } +} + +class HK[M[_]](val v: Int) extends AnyVal { + def hk[N[_]]: Unit = if (false) hk[M] else () +} + |