Closed
Description
Compiler version
All Scala 3 versions
Minimized code
trait Ptr[T]
object aliases:
import structs.*
type UCharIteratorReserved = Ptr[UCharIterator]
object UCharIteratorReserved:
def iterator: UCharIterator = ???
object structs:
import aliases.{*, given}
opaque type UCharIterator = Ptr[UCharIteratorReserved]
object UCharIterator:
def reservedFn: UCharIteratorReserved = ???
Output (click arrow to expand)
Error while emitting main.scala
java.lang.StackOverflowError while running genBCode on /Users/wmazur/projects/sandbox/main.scala
java.lang.StackOverflowError while compiling /Users/wmazur/projects/sandbox/main.scala
Exception in thread "main" java.lang.StackOverflowError
at dotty.tools.dotc.core.Types$Type.dealias1(Types.scala:1384)
at dotty.tools.dotc.core.Types$Type.dealias(Types.scala:1407)
at dotty.tools.dotc.transform.GenericSignatures$.jsig$1(GenericSignatures.scala:238)
at dotty.tools.dotc.transform.GenericSignatures$.boxedSig$1(GenericSignatures.scala:68)
at dotty.tools.dotc.transform.GenericSignatures$.argSig$1(GenericSignatures.scala:195)
at dotty.tools.dotc.transform.GenericSignatures$.classSig$1$$anonfun$1(GenericSignatures.scala:229)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.transform.GenericSignatures$.classSig$1(GenericSignatures.scala:229)
at dotty.tools.dotc.transform.GenericSignatures$.jsig$1(GenericSignatures.scala:288)
at dotty.tools.dotc.transform.GenericSignatures$.boxedSig$1(GenericSignatures.scala:68)
at dotty.tools.dotc.transform.GenericSignatures$.argSig$1(GenericSignatures.scala:195)
at dotty.tools.dotc.transform.GenericSignatures$.classSig$1$$anonfun$1(GenericSignatures.scala:229)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
...
Related issue
When types are defined in the same scope, the incremental compilation would fail
// Fails with : `scala-cli compile main.scala`
// Compiles with : `scala-cli compile main.scala --server=false`
trait Ptr[T]
type UCharIteratorReserved = Ptr[UCharIterator]
opaque type UCharIterator = Ptr[UCharIteratorReserved]
Error: Encountered a StackOverflowError coming from the compiler. You might need to restart your Bloop build server:
dotty.tools.dotc.sbt.ExtractAPICollector.computeType(ExtractAPI.scala:466)
dotty.tools.dotc.sbt.ExtractAPICollector.apiType$$anonfun$1(ExtractAPI.scala:463)
scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:454)
dotty.tools.dotc.sbt.ExtractAPICollector.apiType(ExtractAPI.scala:463)
dotty.tools.dotc.sbt.ExtractAPICollector.processArg$1(ExtractAPI.scala:501)
dotty.tools.dotc.sbt.ExtractAPICollector.$anonfun$10(ExtractAPI.scala:505)
scala.collection.immutable.List.map(List.scala:246)
dotty.tools.dotc.sbt.ExtractAPICollector.computeType(ExtractAPI.scala:505)
dotty.tools.dotc.sbt.ExtractAPICollector.apiType$$anonfun$1(ExtractAPI.scala:463)
...
Error compiling project (Scala 3.3.0, JVM (17))