summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-05-31 23:49:52 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-07-10 10:44:20 +1000
commita90d1f01d603d9f00445ead48a87a051cd0ede15 (patch)
treeacd71415af0d2a487ad7fa7b31afaa2fafe4fddd /test/files/neg
parent07fc7bb2f718f335058ea84700778827747a6314 (diff)
downloadscala-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/neg')
-rw-r--r--test/files/neg/t6574.check7
-rw-r--r--test/files/neg/t6574.scala10
2 files changed, 17 insertions, 0 deletions
diff --git a/test/files/neg/t6574.check b/test/files/neg/t6574.check
new file mode 100644
index 0000000000..c67b4ed804
--- /dev/null
+++ b/test/files/neg/t6574.check
@@ -0,0 +1,7 @@
+t6574.scala:4: error: could not optimize @tailrec annotated method notTailPos$extension: it contains a recursive call not in tail position
+ println("tail")
+ ^
+t6574.scala:8: error: could not optimize @tailrec annotated method differentTypeArgs$extension: it is called recursively with different type arguments
+ {(); new Bad[String, Unit](0)}.differentTypeArgs
+ ^
+two errors found
diff --git a/test/files/neg/t6574.scala b/test/files/neg/t6574.scala
new file mode 100644
index 0000000000..bba97ad62e
--- /dev/null
+++ b/test/files/neg/t6574.scala
@@ -0,0 +1,10 @@
+class Bad[X, Y](val v: Int) extends AnyVal {
+ @annotation.tailrec final def notTailPos[Z](a: Int)(b: String) {
+ this.notTailPos[Z](a)(b)
+ println("tail")
+ }
+
+ @annotation.tailrec final def differentTypeArgs {
+ {(); new Bad[String, Unit](0)}.differentTypeArgs
+ }
+}