diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-06-27 14:30:54 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-06-27 14:30:54 +0200 |
commit | e5964e26fef818390694ecdd91e7fd1cad60b210 (patch) | |
tree | 937bf29334e4dee5e8af2424ca90c7ce4d456cce /test/files/neg | |
parent | 44f10291622058d11d75dc8f3ad35b582247799c (diff) | |
parent | 299594e63a925c3e6042c6fd920de2f359417cbd (diff) | |
download | scala-e5964e26fef818390694ecdd91e7fd1cad60b210.tar.gz scala-e5964e26fef818390694ecdd91e7fd1cad60b210.tar.bz2 scala-e5964e26fef818390694ecdd91e7fd1cad60b210.zip |
Merge pull request #3832 from jrudolph/w/fix-tailrec
SI-8657 don't miss tailrec defs in more positions
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/tailrec-4.check | 16 | ||||
-rw-r--r-- | test/files/neg/tailrec-4.scala | 35 |
2 files changed, 51 insertions, 0 deletions
diff --git a/test/files/neg/tailrec-4.check b/test/files/neg/tailrec-4.check new file mode 100644 index 0000000000..3ec3274478 --- /dev/null +++ b/test/files/neg/tailrec-4.check @@ -0,0 +1,16 @@ +tailrec-4.scala:6: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position + @tailrec def foo: Int = foo + 1 + ^ +tailrec-4.scala:11: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position + @tailrec def foo: Int = foo + 1 + ^ +tailrec-4.scala:17: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position + @tailrec def foo: Int = foo + 1 + ^ +tailrec-4.scala:23: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position + @tailrec def foo: Int = foo + 1 + ^ +tailrec-4.scala:31: error: could not optimize @tailrec annotated method foo: it contains a recursive call not in tail position + @tailrec def foo: Int = foo + 1 + ^ +5 errors found diff --git a/test/files/neg/tailrec-4.scala b/test/files/neg/tailrec-4.scala new file mode 100644 index 0000000000..4822799dfa --- /dev/null +++ b/test/files/neg/tailrec-4.scala @@ -0,0 +1,35 @@ +import annotation._ + +object Tail { + def tcInFunc: Unit = { + () => { + @tailrec def foo: Int = foo + 1 + } + } + def tcInBooleanExprFirstOp(x: Int, v: Int): Boolean = { + { + @tailrec def foo: Int = foo + 1 + foo + } == v && true + } + def tcInBooleanExprSecondOp(x: Int, v: Int): Boolean = { + true && { + @tailrec def foo: Int = foo + 1 + foo + } == v + } + def tcInIfCond(x: Int, v: Int): Boolean = { + if ({ + @tailrec def foo: Int = foo + 1 + foo + } == v) true else false + } + def tcInPatternGuard(x: Int, v: Int): Boolean = + v match { + case _ if + { + @tailrec def foo: Int = foo + 1 + foo == 42 + } => true + } +} |