Permalink
Browse files

SI-7013 Scaladoc: Fix StackOverflowError

No one see the result value of parse and if so, it's tail-recursive.
  • Loading branch information...
1 parent 144671e commit df292901c3dd9688d1dabf4ebaa9d73a23ebfe80 @kzys kzys committed Mar 19, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/compiler/scala/tools/nsc/doc/html/SyntaxHigh.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.doc.html
import scala.xml.NodeSeq
+import scala.annotation.tailrec
/** Highlight the syntax of Scala code appearing in a `{{{` wiki block
* (see method `HtmlPage.blockToHtml`).
@@ -209,9 +210,9 @@ private[html] object SyntaxHigh {
out.toString
}
- def parse(pre: String, i: Int): Int = {
+ @tailrec def parse(pre: String, i: Int): Unit = {
out append pre
- if (i == buf.length) return i
+ if (i == buf.length) return
buf(i) match {
case '\n' =>
parse("\n", i+1)
@@ -277,7 +278,6 @@ private[html] object SyntaxHigh {
} else
parse(buf(i).toChar.toString, i+1)
}
- i
}
parse("", 0)

0 comments on commit df29290

Please sign in to comment.