Closed
Description
Compiler version
3.1.2
Fails with nightly (13.05.2022)
Works with 3.1.1
First bad commit f50b55c
Minimized code
Based on https://github.com/jcouyang/meow/blob/22e5a47682ec15861f45d71692f640bd218e0044/src/main/scala/Semigroup.scala#L24 and
https://github.com/jcouyang/meow/blob/9513eb8b314c2256d0e3b95e834ebee86078484c/src/main/scala/Prelude.scala
//> using scala "3.1.2"
object prelude:
export Semigroup.*
trait Semigroup[A]:
def scombine(x: A, y: A): A
object Semigroup:
def scombine[A](x: A, y: A) = (s: Semigroup[A]) ?=> s.scombine(x,y)
Output (click arrow to expand)
exception while typing final def scombine[A](x: A, y: A): (Semigroup[A]) ?=> A = Semigroup.scombine[A](x, y) of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing @SourceFile("test.scala") final module class prelude() extends Object() {
private def writeReplace(): AnyRef = new scala.runtime.ModuleSerializationProxy(classOf[prelude.type])
final def scombine[A](x: A, y: A): (Semigroup[A]) ?=> A = Semigroup.scombine[A](x, y)
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
final lazy module val prelude: prelude = new prelude()
@SourceFile("test.scala") final module class prelude() extends Object() {
private def writeReplace(): AnyRef = new scala.runtime.ModuleSerializationProxy(classOf[prelude.type])
final def scombine[A](x: A, y: A): (Semigroup[A]) ?=> A = Semigroup.scombine[A](x, y)
}
@SourceFile("test.scala") trait Semigroup[A]() extends Object {
private type A
def scombine(x: A, y: A): A
}
final lazy module val Semigroup: Semigroup = new Semigroup()
@SourceFile("test.scala") final module class Semigroup() extends Object() {
private def writeReplace(): AnyRef = new scala.runtime.ModuleSerializationProxy(classOf[Semigroup.type])
@ContextResultCount(1) def scombine[A](x: A, y: A): (Semigroup[A]) ?=> A =
{
def $anonfun(using s: Semigroup[A]): A = s.scombine(x, y)
closure($anonfun)
}
}
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
exception occurred while compiling test.scala
java.lang.AssertionError: assertion failed while compiling test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
at dotty.tools.dotc.transform.Erasure$Boxing$.adaptToType(Erasure.scala:388)
at dotty.tools.dotc.transform.Erasure$Typer.adapt(Erasure.scala:1041)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2994)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2998)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3114)
at dotty.tools.dotc.typer.Typer.$anonfun$48(Typer.scala:2302)
at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2302)
at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:931)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2841)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2928)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2994)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2998)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3020)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3070)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1029)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2507)
at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1019)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2853)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2857)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2928)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2994)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2998)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3020)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3070)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1029)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2636)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2898)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2929)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2994)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2998)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3114)
at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:311)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:312)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:225)
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:1328)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:236)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:244)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:253)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:253)
at dotty.tools.dotc.Run.compileSources(Run.scala:186)
at dotty.tools.dotc.Run.compile(Run.scala:170)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
at dotty.tools.dotc.Driver.process(Driver.scala:195)
at dotty.tools.dotc.Driver.process(Driver.scala:163)
at dotty.tools.dotc.Driver.process(Driver.scala:175)
at dotty.tools.dotc.Driver.main(Driver.scala:205)
at dotty.tools.dotc.Main.main(Main.scala)