Description
Compiler version
main: 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-c90ad6b
3.3.1
originally discovered on 3.3.1, used main for isolation and for the logs below
HOWEVER, works on 3.2.2
Minimized code
sealed trait A:
class B extends A
def compute(a: A): Boolean =
a match
case b: A#B => true
Output (click arrow to expand)
With 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-c90ad6b (failing):
Identical output for 3.3.1
[�[0minfo�[0m] entering *experimental* thin client - BEEP WHIRR
[�[0minfo�[0m] terminate the server with `shutdown`
> run -color:never /tmp/dotty-test/rec.scala
[info] running (fork) dotty.tools.dotc.Main -classpath /home/sankalp/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:/home/sankalp/projects/scala-spree/dotty-working/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.0-RC1-bin-SNAPSHOT.jar -color:never /tmp/dotty-test/rec.scala
Exception in thread "main" java.lang.StackOverflowError
unhandled exception while running MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher} on /tmp/dotty-test/rec.scala
An unhandled exception was thrown in the compiler.
Please file a crash report here:
https://github.com/lampepfl/dotty/issues/new/choose
while compiling: /tmp/dotty-test/rec.scala
during phase: MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher}
mode: Mode(ImplicitsEnabled)
library version: version 2.13.10
compiler version: version 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-c90ad6b
settings: -classpath /home/sankalp/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:/home/sankalp/projects/scala-spree/dotty-working/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.0-RC1-bin-SNAPSHOT.jar -color never
tree: EmptyTree
tree position: :<unknown>
tree type: <notype>
symbol: val <none>
call site: package <root> in module class <root>
== Source file context for tree position ==
at dotty.tools.dotc.core.Types$LambdaType.paramRefs(Types.scala:3703)
at dotty.tools.dotc.core.Types$LambdaType.paramRefs$(Types.scala:3680)
at dotty.tools.dotc.core.Types$MethodOrPoly.paramRefs(Types.scala:3766)
at dotty.tools.dotc.core.OrderingConstraint.adjustDeps$$anonfun$2(OrderingConstraint.scala:431)
at dotty.tools.dotc.core.OrderingConstraint.adjustDeps$$anonfun$adapted$1(OrderingConstraint.scala:432)
at scala.collection.immutable.Range.foreach(Range.scala:190)
at dotty.tools.dotc.core.OrderingConstraint.adjustDeps(OrderingConstraint.scala:432)
at dotty.tools.dotc.core.OrderingConstraint.init(OrderingConstraint.scala:535)
at dotty.tools.dotc.core.OrderingConstraint.add(OrderingConstraint.scala:513)
at dotty.tools.dotc.core.OrderingConstraint.add(OrderingConstraint.scala:506)
at dotty.tools.dotc.core.ConstraintHandling.addToConstraint(ConstraintHandling.scala:768)
at dotty.tools.dotc.core.ConstraintHandling.addToConstraint$(ConstraintHandling.scala:29)
at dotty.tools.dotc.core.TypeComparer.addToConstraint(TypeComparer.scala:31)
at dotty.tools.dotc.core.TypeComparer$.addToConstraint(TypeComparer.scala:3116)
at dotty.tools.dotc.typer.ProtoTypes$.constrained(ProtoTypes.scala:747)
at dotty.tools.dotc.typer.ProtoTypes$.newTypeVar(ProtoTypes.scala:780)
at dotty.tools.dotc.core.TypeOps$InferPrefixMap$1.apply(TypeOps.scala:892)
at dotty.tools.dotc.core.Types$TypeMap.op$proxy18$1(Types.scala:5823)
at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5823)
at dotty.tools.dotc.core.TypeOps$InferPrefixMap$1.apply(TypeOps.scala:895)
at dotty.tools.dotc.core.TypeOps$.instantiateToSubType(TypeOps.scala:901)
at dotty.tools.dotc.core.TypeOps$.refineUsingParent(TypeOps.scala:757)
at dotty.tools.dotc.transform.patmat.SpaceEngine$.$anonfun$13(Space.scala:650)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.transform.patmat.SpaceEngine$.rec$1(Space.scala:661)
at dotty.tools.dotc.transform.patmat.SpaceEngine$.decompose(Space.scala:669)
at dotty.tools.dotc.transform.patmat.SpaceEngine$Parts$.unapply(Space.scala:689)
at dotty.tools.dotc.transform.patmat.SpaceEngine$.rec$1(Space.scala:624)
<STACK TRACE TRIMMED BY PR AUTHOR>
With 3.2.2 (working):
sbt:rectest> compile
[info] compiling 2 Scala sources to /tmp/dotty-test/rectest/target/scala-3.2.2/classes ...
[success] Total time: 7 s, completed Nov 23, 2023, 12:53:07 PM
Source and Problem
Discovered as epfl-lara/lisa#190, where we are unable to upgrade from 3.2.2, where this does work, to 3.3.1 as we would like to.