I am receiving the following issue when building some existing scala code. I am on version 0.13 of sbt, 1.8.113 of java 8 and scala 2.12.2.

java.lang.StackOverflowError
at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:714)
at scala.reflect.internal.tpe.TypeMaps$TypeMap.mapOver(TypeMaps.scala:123)
at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:716)
at scala.reflect.internal.tpe.TypeMaps$TypeMap.mapOver(TypeMaps.scala:123)
at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:716)
at scala.reflect.internal.tpe.TypeMaps$TypeMap.mapOver(TypeMaps.scala:123)
at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:716)
at scala.reflect.internal.tpe.TypeMaps$TypeMap.mapOver(TypeMaps.scala:123)
at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:716)
at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:685)
at scala.collection.immutable.List.loop$1(List.scala:173)

You’ve indicated elsewhere that you think https://github.com/scala/bug/issues/9142 may be the problem. That certainly seems plausible. It would be hard to say anything further without knowing more about the code that’s triggering the problem. (As in, you’d need to reduce your code to minimal code that triggers the problem, and then we’d see if what you end up with is basically the same as Denys’s example in the ticket, or if there’s something notably different about it.)

The only workaround I can think of to suggest for that issue is “don’t use recursive type aliases involving structural types”.

Thanks for the response Seth. I inherited a 70 scala file project that contains the offending code. When I build the software in SBT it does not tell me what line of code the SOE is occurring from. Can you tell me how to get the scalac to tell me where the offending line of code is? Is there a quick and easy way to narrow it down?

I inherited a 70 scala file project that contains the offending code. When I build the software in SBT it does not tell me what line of code the SOE is occurring from. Can you tell me how to get the scalac to tell me where the offending line of code is? Is there a quick and easy way to narrow it down?

siliconplains:

Based on what I am seeing, it appears the scala compiler is compiling something in the 2.11.7 jar file and that is causing the error.

That’s unlikely—and there’s nothing to compile in scala-library-2.11.7.jar. The compiler is failing some time it loads some compiled code, but that does not necessarily mean the code it loaded causes the issue.

Please post a gist with the full stack trace. You might need to run last compile:compileIncremental to see that if SBT suppresses it by default.

It can also be helpful to run with -Ytyper-debug -Ylog:all to try to get an idea about what part of the code and compiler intersected just before the crash. You’ll get reams of output, but the end of the log can be interesting.

You can also attach a debugger to the compiler with a breakpoint set on the StackOverflowError. sbt -jvm-debug 5006 compile should open up a remote debug port. Add "org.scala-lang" % "scala-compiler" % "2.11.7" as an libraryDependency to a SBT project and import that into your IDE, or manually add the following to the IDE classpath: