Skip to content

Compiler crash when using CanThrow #20206

Closed
@alexandru

Description

@alexandru

Compiler version

3.4.1

Minimized code

#!/usr/bin/env -S scala-cli shebang

//> using scala "3.4.1"
//> using option -experimental

trait MyEvidence

type ContextFn[+T] = (MyEvidence, CanThrow[Exception]) ?=> T

class Foo:
    def foo: ContextFn[String] =
        "foo"

class Bar:
    val foo = new Foo

    def bar: ContextFn[String] =
        foo.foo +
        "bar"

Output

Compiling project (Scala 3.4.1, JVM (21))
Error compiling project (Scala 3.4.1, JVM (21))
Error: Unexpected error when compiling directio_5eb7d97420-5bb168c9c8: java.lang.AssertionError: assertion failed: bad adapt for this.foo().foo: (using x$1: MyEvidence): String
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.transform.Erasure$Boxing$.adaptToType(Erasure.scala:391)
	at dotty.tools.dotc.transform.Erasure$Typer.adapt(Erasure.scala:1091)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:671)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3088)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
	at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:843)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3113)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:671)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3088)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
	at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:843)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3113)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
	at dotty.tools.dotc.typer.Typer.$anonfun$62(Typer.scala:2603)
	at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2603)
	at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:960)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3095)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1073)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2790)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1049)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3101)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3105)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1073)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2923)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3147)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:174)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:354)
	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:333)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:360)
        ....

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions