Closed
Description
Compiler version
3.6.3-RC1
Minimized code
sealed trait NonPolygon
sealed trait Polygon
sealed trait SymmetryAspect
sealed trait RotationalSymmetry extends SymmetryAspect
sealed trait MaybeRotationalSymmetry extends SymmetryAspect
enum Shape:
case Circle extends Shape with NonPolygon with RotationalSymmetry
case Triangle extends Shape with Polygon with MaybeRotationalSymmetry
case Square extends Shape with Polygon with RotationalSymmetry
object Shape:
def hasPolygon(
rotationalSyms: Vector[Shape & RotationalSymmetry],
maybeSyms: Vector[Shape & MaybeRotationalSymmetry]
): Boolean =
val all = rotationalSyms.concat(maybeSyms)
all.exists:
case _: Polygon => true
case _ => false
Output
[error] ## Exception when compiling...
[error] java.lang.StackOverflowError
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation$$anon$3.applyOrElse(SymDenotations.scala:1731)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation$$anon$3.applyOrElse(SymDenotations.scala:1731)
[error] scala.collection.immutable.List.collect(List.scala:268)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.children(SymDenotations.scala:1731)
[error] dotty.tools.dotc.core.SymUtils.hasAnonymousChild(SymUtils.scala:331)
[error] dotty.tools.dotc.core.TypeComparer.isDecomposable$1(TypeComparer.scala:3196)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjointClasses(TypeComparer.scala:3222)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjointClasses$$anonfun$1(TypeComparer.scala:3227)
[error] scala.collection.immutable.List.forall(List.scala:387)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjointClasses(TypeComparer.scala:3227)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjointClasses$$anonfun$1(TypeComparer.scala:3227)
[error] scala.collection.immutable.List.forall(List.scala:387)
... //Stack keeps on repeating
```
## Expectation
The code should compile without any errors or warnings.
## Observations
- If you add the explicit return type as in `val all: Vector[Any] =...` or `val all:Vector[Shape] = ...`, the code compiles.
- If either `RotationalSymmetry` or `MaybeRotationalSymmetry` do not extend `SymmetryAspect`, the code compiles.
- If using scala 3 LTS (3.3.4), without any changes to the code, the code compiles.