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

classOf[scala.Singleton] compiler crash #19530

Closed
xuwei-k opened this issue Jan 25, 2024 · 1 comment · Fixed by #19550
Closed

classOf[scala.Singleton] compiler crash #19530

xuwei-k opened this issue Jan 25, 2024 · 1 comment · Fixed by #19550
Assignees
Labels
area:erasure area:typer itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Milestone

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Jan 25, 2024

Compiler version

  • 3.3.1
  • 3.4.0-RC3
  • 3.4.1-RC1-bin-20240124-7c3edc5-NIGHTLY

Minimized code

object A {
  def x = classOf[scala.Singleton]
}

Output (click arrow to expand)

[info] compiling 1 Scala source to /Users/kenji/classOf-scala-Singleton-crash/target/scala-3.4.0-RC3/classes ...

  exception while retyping classOf[Singleton] of class Literal # -1

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

     while compiling: /Users/kenji/classOf-scala-Singleton-crash/A.scala
        during phase: MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, etaReduce, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.0-RC3
            settings: -bootclasspath /Users/kenji/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.0-RC3/scala3-library_3-3.4.0-RC3.jar:/Users/kenji/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -classpath /Users/kenji/classOf-scala-Singleton-crash/target/scala-3.4.0-RC3/classes -d /Users/kenji/classOf-scala-Singleton-crash/target/scala-3.4.0-RC3/classes

[error] ## Exception when compiling 1 sources to /Users/kenji/classOf-scala-Singleton-crash/target/scala-3.4.0-RC3/classes
[error] java.lang.UnsupportedOperationException: openForMutations
[error] dotty.tools.package$.unsupported(package.scala:9)
[error] dotty.tools.dotc.core.Scopes$Scope.openForMutations(Scopes.scala:178)
[error] dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$apply(TypeErasure.scala:728)
[error] dotty.tools.dotc.core.TypeErasure.eraseInfo(TypeErasure.scala:817)
[error] dotty.tools.dotc.core.TypeErasure$.transformInfo(TypeErasure.scala:273)
[error] dotty.tools.dotc.transform.Erasure.transform(Erasure.scala:96)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:831)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.goForward$1(Denotations.scala:848)
[error] dotty.tools.dotc.core.Denotations$SingleDenotation.current(Denotations.scala:877)
[error] dotty.tools.dotc.core.Types$NamedType.computeDenot(Types.scala:2467)
[error] dotty.tools.dotc.core.Types$NamedType.denot(Types.scala:2430)
[error] dotty.tools.dotc.core.Types$NamedType.info(Types.scala:2419)
[error] dotty.tools.dotc.core.Types$Type.isRef(Types.scala:200)
[error] dotty.tools.dotc.ast.tpd$.clsOf(tpd.scala:1345)
[error] dotty.tools.dotc.transform.Erasure$Typer.typedLiteral(Erasure.scala:639)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3117)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3198)
[error] dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
[error] dotty.tools.dotc.typer.Typer.$anonfun$62(Typer.scala:2602)
[error] dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
[error] dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2602)
[error] dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:959)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3096)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3301)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3347)
[error] dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1058)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2789)
[error] dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1047)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3102)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3106)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3301)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3347)
[error] dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1058)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2922)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3148)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3198)
[error] dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
[error] dotty.tools.dotc.transform.Erasure.run(Erasure.scala:143)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:354)
[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:333)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:360)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
[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:337)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:348)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:357)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:71)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:357)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:261)
[error] dotty.tools.dotc.Run.compile(Run.scala:246)
[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:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[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$5(Incremental.scala:180)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[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:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:419)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:172)
[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:2371)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[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:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319)
[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:515)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] java.base/java.lang.Thread.run(Thread.java:829)
@xuwei-k xuwei-k added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 25, 2024
@WojciechMazur
Copy link
Contributor

It worked in 3.0.x, so we're a dealing with long standing regression.
Last good release: 3.0.3-RC1-bin-20210813-e4b421c-NIGHTLY
First bad release: 3.0.3-RC1-bin-20210815-1524a5a-NIGHTLY
Bisect points to 3f1b86f

@WojciechMazur WojciechMazur added area:typer area:erasure regression This worked in a previous version but doesn't anymore and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 25, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 28, 2024
@noti0na1 noti0na1 linked a pull request Jan 30, 2024 that will close this issue
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:erasure area:typer itype:bug itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
4 participants