Skip to content

crash on compilable code: assertion failed: failure to construct path from... #1755

Closed
@helloqirun

Description

@helloqirun

Maybe it's related to issue #1664.

scalac can compile but dotty crashes.

$ cat abc.scala

class hierarOverload {
  trait AB {
    type TB
    protected trait A { val entities: List[TB] }
    protected trait B
  }
  object NAnB {
    type TB = nB
    type TA = nA
    class nA { List[nB]() }
    class nB {}
  }
  def foo = { val t = new NAnB.TB() }
}

$ dotc abc.scala

exception while typing NAnB$.this of class class dotty.tools.dotc.ast.Trees$This # 475
exception while typing new hierarOverload.NAnB.nB() of class class dotty.tools.dotc.ast.Trees$Apply # 325
exception while typing val t: hierarOverload.this.NAnB.nB = new hierarOverload.NAnB.nB() of class class dotty.tools.dotc.ast.Trees$ValDef # 326
exception while typing {
  val t: hierarOverload.this.NAnB.nB = new hierarOverload.NAnB.nB()
  ()
} of class class dotty.tools.dotc.ast.Trees$Block # 327
exception while typing def foo: Unit =
  {
    val t: hierarOverload.this.NAnB.nB = new hierarOverload.NAnB.nB()
    ()
  } of class class dotty.tools.dotc.ast.Trees$DefDef # 328
exception while typing @scala.annotation.internal.SourceFile("abc.scala") class hierarOverload()
   extends
 Object() {
  <trait> trait AB() extends Object() {
    type TB = ?
    protected <trait> interface trait A() extends Object {
      <accessor> def entities:
        scala.collection.immutable.List{
          scala$collection$immutable$List$$A =+ AB.this.TB
        }
    }
    protected <trait> interface trait B() extends Object {}
    final def hierarOverload$AB$$$outer: hierarOverload
  }
  final lazy <accessor> module def NAnB: hierarOverload.this.NAnB$ =
    new hierarOverload.this.NAnB$()
  final module class NAnB$() extends Object() {
    type TBhierarOverload.NAnB.nB
    type TAhierarOverload.NAnB.nA
    class nA() extends Object() {
      List.apply[hierarOverload.NAnB.nB](
        Predef.wrapRefArray[hierarOverload.NAnB.nB]([ : hierarOverload.NAnB.nB])
      )
      private <accessor> def $outer: hierarOverload.this.NAnB$
      final def hierarOverload$NAnB$nA$$$outer: hierarOverload.this.NAnB$ =
        nA.this.$outer
    }
    class nB() extends Object() {
      private <accessor> def $outer: hierarOverload.this.NAnB$
      final def hierarOverload$NAnB$nB$$$outer: hierarOverload.this.NAnB$ =
        nB.this.$outer
    }
  }
  def foo: Unit =
    {
      val t: hierarOverload.this.NAnB.nB = new hierarOverload.NAnB.nB()
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 358
exception while typing package <empty> {
  @scala.annotation.internal.SourceFile("abc.scala") class hierarOverload()
     extends
   Object() {
    <trait> trait AB() extends Object() {
      type TB = ?
      protected <trait> interface trait A() extends Object {
        <accessor> def entities:
          scala.collection.immutable.List{
            scala$collection$immutable$List$$A =+ AB.this.TB
          }
      }
      protected <trait> interface trait B() extends Object {}
      final def hierarOverload$AB$$$outer: hierarOverload
    }
    final lazy <accessor> module def NAnB: hierarOverload.this.NAnB$ =
      new hierarOverload.this.NAnB$()
    final module class NAnB$() extends Object() {
      type TBhierarOverload.NAnB.nB
      type TAhierarOverload.NAnB.nA
      class nA() extends Object() {
        List.apply[hierarOverload.NAnB.nB](
          Predef.wrapRefArray[hierarOverload.NAnB.nB](
            [ : hierarOverload.NAnB.nB]
          )
        )
        private <accessor> def $outer: hierarOverload.this.NAnB$
        final def hierarOverload$NAnB$nA$$$outer: hierarOverload.this.NAnB$ =
          nA.this.$outer
      }
      class nB() extends Object() {
        private <accessor> def $outer: hierarOverload.this.NAnB$
        final def hierarOverload$NAnB$nB$$$outer: hierarOverload.this.NAnB$ =
          nB.this.$outer
      }
    }
    def foo: Unit =
      {
        val t: hierarOverload.this.NAnB.nB = new hierarOverload.NAnB.nB()
        ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 359

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: failure to construct path from value t/method foo/class hierarOverload/package <empty>/package <root> to `this` of object NAnB in class hierarOverload;
class hierarOverload does not have an outer accessor
	at scala.Predef$.assert(Predef.scala:165)
	at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.loop$1(ExplicitOuter.scala:341)
	at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.path$extension(ExplicitOuter.scala:347)
	at dotty.tools.dotc.transform.Erasure$Typer.typedThis(Erasure.scala:395)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1455)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1495)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:95)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1505)
	at dotty.tools.dotc.typer.Typer$$anonfun$typed$2.apply(Typer.scala:1503)
	at dotty.tools.dotc.reporting.Reporting$class.traceIndented(Reporter.scala:136)
	at dotty.tools.dotc.core.Contexts$Context.traceIndented(Contexts.scala:57)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1503)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1555)
<snipped>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions