Closed
Description
Compiler version
3.1.2 & 3.1.1 throw the exception below
Something that scala-cli describes as 3.2.0-RC1-bin-20220412-1503044-NIGHTLY also has the same issue
2.13.8 OK
Minimized code
trait Core {
class Base[T]()
}
class Module(val core: Core) {
object Indirection {
class Extension[T]() extends core.Base[T]()
}
}
Note, this works if any of the following changes is applied
• Base is a trait
• Base has no type parameters
• Indirection is removed
• Module becomes a function
Output (click arrow to expand)
The gist of the crash seems to be:
object Indirection in class Module does not have an outer accessor
exception while typing new Module.this.core.Base[T]() of class class dotty.tools.dotc.ast.Trees$Apply # -1
exception while typing class Extension[T]() extends Module.this.core.Base[T]() {
private type T
private val $outer: Module.this.Indirection
final def Module$Indirection$Extension$$$outer: Module.this.Indirection =
Extension.this.$outer
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing final module class Indirection() extends Object() {
class Extension[T]() extends Module.this.core.Base[T]() {
private type T
private val $outer: Module.this.Indirection
final def Module$Indirection$Extension$$$outer: Module.this.Indirection =
Extension.this.$outer
}
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing @SourceFile("test2.scala") class Module(core: Core) extends Object() {
def core: Core
final lazy module def Indirection: Module.this.Indirection =
new Module.this.Indirection()
final module class Indirection() extends Object() {
class Extension[T]() extends Module.this.core.Base[T]() {
private type T
private val $outer: Module.this.Indirection
final def Module$Indirection$Extension$$$outer: Module.this.Indirection =
Extension.this.$outer
}
}
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
@SourceFile("test2.scala") trait Core() extends Object {
class Base[T]() extends Object() {
private type T
private val $outer: Core
final def Core$Base$$$outer: Core = Base.this.$outer
}
}
@SourceFile("test2.scala") class Module(core: Core) extends Object() {
def core: Core
final lazy module def Indirection: Module.this.Indirection =
new Module.this.Indirection()
final module class Indirection() extends Object() {
class Extension[T]() extends Module.this.core.Base[T]() {
private type T
private val $outer: Module.this.Indirection
final def Module$Indirection$Extension$$$outer: Module.this.Indirection
=
Extension.this.$outer
}
}
}
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
exception occurred while compiling $HOME/test2.scala
java.lang.AssertionError: assertion failed: failure to construct path from constructor Extension/class Extension/object Indirection/class Module/package <empty>/package <root> to `this` of class Module;
object Indirection in class Module does not have an outer accessor while compiling $HOME/test2.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: failure to construct path from constructor Extension/class Extension/object Indirection/class Module/package <empty>/package <root> to `this` of class Module;
object Indirection in class Module does not have an outer accessor
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.loop$1(ExplicitOuter.scala:419)
at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.path$extension(ExplicitOuter.scala:438)
at dotty.tools.dotc.ast.tpd$.followOuterLinks(tpd.scala:423)
at dotty.tools.dotc.ast.tpd$.ref(tpd.scala:413)
at dotty.tools.dotc.ast.tpd$.singleton(tpd.scala:429)
at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.outerArg$1(ExplicitOuter.scala:380)
at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.args$extension(ExplicitOuter.scala:392)
at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:824)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2809)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
at dotty.tools.dotc.typer.Typer.typedParent$1(Typer.scala:2366)
at dotty.tools.dotc.typer.Typer.$anonfun$48(Typer.scala:2441)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:92)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:108)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2441)
at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1020)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2797)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2801)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1030)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2454)
at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1020)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2797)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2801)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1030)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2454)
at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1020)
at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2797)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2801)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1030)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2581)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2842)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
at scala.collection.immutable.List.map(List.scala:246)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
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:270)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
at dotty.tools.dotc.Run.compileUnits(Run.scala:287)
at dotty.tools.dotc.Run.compileSources(Run.scala:220)
at dotty.tools.dotc.Run.compile(Run.scala:204)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
at dotty.tools.scripting.ScriptingDriver.compileAndRun(ScriptingDriver.scala:21)
at dotty.tools.scripting.Main$.main(Main.scala:43)
at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:248)
at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:267)
at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)