-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
compiler crashfixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
Milestone
Description
reproduction steps
Compiler crashes with StackOverflowError
for this code.
trait A[T] {
type Result <: C
}
trait B[T] { self: A[_] =>
type Result <: self.Result with D
}
trait C
trait D
new A[String] with B[Int]
Although, if we remove trait D
from the mixin.
trait B[T] { self: A[_] =>
type Result <: self.Result // with D
}
The compiler is able to detect an illegal cyclic reference, before going into StackOverflowError
.
[error] illegal cyclic reference involving type Result
[error] new A[String] with B[Int]
problem
Compiler crashes with:
[error] java.lang.StackOverflowError
(This stack trace bit below repeats itself...)
[error] scala.reflect.internal.Types.defineBaseClassesOfCompoundType$(Types.scala:1778)
[error] scala.reflect.internal.SymbolTable.defineBaseClassesOfCompoundType(SymbolTable.scala:28)
[error] scala.reflect.internal.Types$CompoundType.baseClasses(Types.scala:1639)
[error] scala.reflect.internal.Types$SubType.baseClasses(Types.scala:1095)
[error] scala.reflect.internal.Types$AbstractTypeRef.baseClasses(Types.scala:2336)
[error] scala.reflect.internal.Types$AbstractTypeRef.baseClasses$(Types.scala:2336)
[error] scala.reflect.internal.Types$AbstractNoArgsTypeRef.baseClasses(Types.scala:2729)
[error] scala.reflect.internal.Definitions$DefinitionsClass.functionNBaseType(Definitions.scala:947)
[error] scala.reflect.internal.Symbols$ClassSymbol.$anonfun$anonOrRefinementString$1(Symbols.scala:3470)
[error] scala.reflect.internal.Symbols$ClassSymbol.anonOrRefinementString(Symbols.scala:3470)
[error] scala.reflect.internal.Symbols$ClassSymbol.toString(Symbols.scala:3477)
[error] java.base/java.lang.String.valueOf(String.java:3352)
[error] java.base/java.lang.StringBuilder.append(StringBuilder.java:166)
[error] scala.reflect.internal.Types.defineBaseClassesOfCompoundType(Types.scala:1794)
running environment
compiled with sbt 1.3.10
scala version 2.13.2
expectation
In similar cases, the compiler is able to detect infinite loops before getting into them, and provide a meaningful error message to the user.
Metadata
Metadata
Assignees
Labels
compiler crashfixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)