Scalaのコンパイル時にStackOverflowErrorが出てしまう

EclipseとかでScalaソースコードを書いていると、たまーにうまくビルドできないことがあります。

Mavenでビルドしていると、こんな感じになります。

[ERROR] Caused by: java.lang.StackOverflowError
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4078)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4145)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4151)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3964)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4078)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4145)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4151)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3964)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4078)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4145)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4151)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3964)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4078)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4145)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4151)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3964)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4078)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4145)
[INFO]  at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:4153)
.....

どうやら本当にstackのサイズが足らないようで、拡張してやるとうまくいきます。
Eclipseの場合は、eclipse.iniに -Xss1m と追加してやればOKです。
Mavenの場合は、Scalaコンパイラが独立したVMで起動するので、Maven起動時のVM引数ではなく、pom.xmlに記述します。

  <plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <executions>
        <execution>
        <id>compile</id>
        <goals>
            <goal>compile</goal>
        </goals>
        <phase>compile</phase>
        </execution>

        <execution>
        <id>test-compile</id>
        <goals>
            <goal>testCompile</goal>
        </goals>
        <phase>test-compile</phase>
        </execution>
    </executions>
    <configuration>
        <scalaVersion>2.8.0.final</scalaVersion>
        <jvmArgs><jvmArg>-Xss1m</jvmArg></jvmArgs>
    </configuration>
  </plugin>

なお、stackのデフォルトサイズは、あんまりはっきりとした情報源は見つかりませんでしたが、32bitのJVMではデフォルト256k、64bitでは1Mのようです。

ソースコードの1ステートメントが長すぎるんですかね・・・