Skip to content

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

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
helloqirun opened this issue Nov 30, 2016 · 1 comment

Comments

@helloqirun
Copy link

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>
@liufengyun
Copy link
Contributor

Thanks @helloqirun , report confirmed.

For anyone interested in investigating this issue, the exception happens in phase ExplicitOuter. Following minimised version produce the same stacktrace:

class hierarOverload {
  object NAnB {
    type TB = nB
    class nB
  }
  def foo = { val t = new NAnB.TB() }
}

If there's no type alias, everything works fine:

class hierarOverload {
  object NAnB {
    class nB
  }
  def foo = { val t = new NAnB.nB() }
}

@odersky odersky self-assigned this Dec 2, 2016
odersky added a commit that referenced this issue Dec 17, 2016
Fix #1755: Make sure references in outer args are accessible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants