Skip to content

Unhandled exception while running erasure #21433

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

Closed
abosshard opened this issue Aug 25, 2024 · 0 comments · Fixed by #21517
Closed

Unhandled exception while running erasure #21433

abosshard opened this issue Aug 25, 2024 · 0 comments · Fixed by #21517

Comments

@abosshard
Copy link

Compiler version

3.5.0, 3.4.3

Minimized code

trait A[T]:
  type R = T ?=> Unit
  def f: R = ()

class B extends A[Int]:
  override def f: R = ()

Output (click arrow to expand)

  unhandled exception while running erasure on Bug.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: Bug.scala
        during phase: erasure
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.0
            settings: 

Exception in thread "main" scala.MatchError: TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class B)),type R) (of class dotty.tools.dotc.core.Types$CachedTypeRef)
	at dotty.tools.dotc.transform.ContextFunctionResults$.recur$1(ContextFunctionResults.scala:105)
	at dotty.tools.dotc.transform.ContextFunctionResults$.contextFunctionResultTypeAfter(ContextFunctionResults.scala:106)
	at dotty.tools.dotc.transform.Bridges.etaExpand$1(Bridges.scala:157)
	at dotty.tools.dotc.transform.Bridges.bridgeRhs$1(Bridges.scala:166)
	at dotty.tools.dotc.transform.Bridges.addBridge$$anonfun$2(Bridges.scala:168)
	at dotty.tools.dotc.ast.tpd$.DefDef(tpd.scala:312)
	at dotty.tools.dotc.transform.Bridges.addBridge(Bridges.scala:168)
	at dotty.tools.dotc.transform.Bridges.addBridgeIfNeeded(Bridges.scala:94)
	at dotty.tools.dotc.transform.Bridges.add(Bridges.scala:178)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1078)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3074)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1056)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3380)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3384)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3476)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3558)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3580)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3626)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1080)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3207)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3426)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3477)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3554)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3558)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3669)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:145)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:380)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:334)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:373)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
	at dotty.tools.dotc.Run.compileSources(Run.scala:282)
	at dotty.tools.dotc.Run.compile(Run.scala:267)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
	at dotty.tools.dotc.Driver.process(Driver.scala:201)
	at dotty.tools.dotc.Driver.process(Driver.scala:169)
	at dotty.tools.dotc.Driver.process(Driver.scala:181)
	at dotty.tools.dotc.Driver.main(Driver.scala:211)
	at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
	at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
	at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)
@abosshard abosshard added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 25, 2024
wjoel added a commit to wjoel/scala3 that referenced this issue Aug 30, 2024
@Gedochao Gedochao added area:erasure and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 2, 2024
wjoel added a commit to wjoel/scala3 that referenced this issue Sep 2, 2024
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
tgodzik pushed a commit to scala/scala3-lts that referenced this issue Apr 21, 2025
tgodzik added a commit to scala/scala3-lts that referenced this issue Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants