Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crashed when pattern matching on an abstract scrutinee, with a sealed trait extended by a private class #21790

Closed
SimonGuilloud opened this issue Oct 16, 2024 · 0 comments · Fixed by #21799 or #21930

Comments

@SimonGuilloud
Copy link

Compiler version

3.5.1

Minimized code

trait S:
  sealed trait A 
  private class CA() extends A 

object O extends S

trait T

def f(e: T) = e match 
  case _: O.A => ()
  case _ => ()

Output

unhandled exception while running MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, checkStatic, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher} on /tmp/scastie9178258913818202660/src/main/scala/main.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.

     while compiling: /tmp/scastie9178258913818202660/src/main/scala/main.scala
        during phase: MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, checkStatic, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.1
            settings: -bootclasspath /home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.1/scala3-library_3-3.5.1.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar -classpath /tmp/scastie9178258913818202660/target/scala-3.5.1/classes:/home/sbtRunnerContainer/.ivy2/local/org.scastie/runtime-scala_3/1.0.0-SNAPSHOT/jars/runtime-scala_3.jar:/home/sbtRunnerContainer/.ivy2/local/org.scastie/api_3/0.30.0-SNAPSHOT/jars/api_3.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/typesafe/play/play-json_3/2.10.0-RC5/play-json_3-2.10.0-RC5.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/typesafe/play/play-functional_3/2.10.0-RC5/play-functional_3-2.10.0-RC5.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.11.4/jackson-core-2.11.4.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.11.4/jackson-annotations-2.11.4.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.11.4/jackson-datatype-jdk8-2.11.4.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.11.4/jackson-datatype-jsr310-2.11.4.jar:/home/sbtRunnerContainer/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.11.4/jackson-databind-2.11.4.jar -d /tmp/scastie9178258913818202660/target/scala-3.5.1/classes -deprecation true -feature true


[error] scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$)
[error] dotty.tools.dotc.core.TypeComparer.disjointnessBoundary$1(TypeComparer.scala:2923)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:2926)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:2866)
[error] dotty.tools.dotc.core.TypeComparer$.provablyDisjoint(TypeComparer.scala:3251)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$$anon$1.applyOrElse(Space.scala:609)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$$anon$1.applyOrElse(Space.scala:607)
[error] scala.collection.immutable.List.collect(List.scala:268)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.rec$1(Space.scala:609)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.decompose(Space.scala:656)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$Parts$.unapply(Space.scala:674)
[error] dotty.tools.dotc.transform.patmat.Typ.decompose(Space.scala:98)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.decompose(Space.scala:115)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.computeSimplify(Space.scala:130)
[error] dotty.tools.dotc.transform.patmat.Space.simplify(Space.scala:67)
[error] dotty.tools.dotc.transform.patmat.Space.simplify$(Space.scala:49)
[error] dotty.tools.dotc.transform.patmat.Typ.simplify(Space.scala:89)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.simplify(Space.scala:112)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.$anonfun$3(Space.scala:125)
[error] scala.collection.immutable.List.map(List.scala:247)
[error] scala.collection.immutable.List.map(List.scala:79)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.computeSimplify(Space.scala:125)
[error] dotty.tools.dotc.transform.patmat.Space.simplify(Space.scala:67)
[error] dotty.tools.dotc.transform.patmat.Space.simplify$(Space.scala:49)
[error] dotty.tools.dotc.transform.patmat.Or.simplify(Space.scala:109)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.simplify(Space.scala:112)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.checkReachability(Space.scala:877)
[error] dotty.tools.dotc.transform.patmat.SpaceEngine$.checkMatch(Space.scala:905)
[error] dotty.tools.dotc.transform.PatternMatcher.transformMatch(PatternMatcher.scala:58)
[error] dotty.tools.dotc.transform.MegaPhase.goMatch(MegaPhase.scala:816)
[error] dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:383)
[error] dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
[error] dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:265)
[error] dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268)
[error] dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
[error] dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
[error] dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
[error] dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:376)
[error] dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
[error] dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272)
[error] dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
[error] dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
[error] dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
[error] dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:396)
[error] dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:399)
[error] dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
[error] dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:481)
[error] dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:493)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:380)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:334)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:373)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:396)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:282)
[error] dotty.tools.dotc.Run.compile(Run.scala:267)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:194)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:249)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:184)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:164)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:164)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:212)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:176)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:454)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:117)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:265)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:409)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:496)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:396)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:170)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2427)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2377)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2375)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] java.base/java.lang.Thread.run(Thread.java:840)
[error]            
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$)
[error] Total time: 0 s, completed Oct 16, 2024, 7:48:41 PM

Expectation

Compiler does not crash. As far as I know, the combination of all elements of the minimized code are require to reproduce the error.

@SimonGuilloud SimonGuilloud added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 16, 2024
@dwijnand dwijnand self-assigned this Oct 16, 2024
@dwijnand dwijnand removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Oct 16, 2024
@WojciechMazur WojciechMazur added this to the 3.6.3 milestone Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment