Skip to content

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

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 6, 2016 · 0 comments

Comments

@helloqirun
Copy link

helloqirun commented Nov 6, 2016

scalac can compile it but dotc crashes.

$ cat abc.scala

object test {
  def f[a](x: a) = {
    def print = (x)
    class A {
      {
        class B { def h = print }
        new B
      }
    }
  }
}

$ dotc abc.scala

exception while transforming print() of class class dotty.tools.dotc.ast.Trees$Apply # 228
exception while transforming def h(): Object = print() of class class dotty.tools.dotc.ast.Trees$DefDef # 229
exception while transforming  extends Object {
  def <init>(): Unit =
    {
      super()
      ()
    }
  def h(): Object = print()
} of class class dotty.tools.dotc.ast.Trees$Template # 253
exception while transforming private class B extends Object {
  def <init>(): Unit =
    {
      super()
      ()
    }
  def h(): Object = print()
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 254
exception while transforming {
  private class B extends Object {
    def <init>(): Unit =
      {
        super()
        ()
      }
    def h(): Object = print()
  }
  new B(): Object
} of class class dotty.tools.dotc.ast.Trees$Block # 255
exception while transforming {
  super()
  {
    private class B extends Object {
      def <init>(): Unit =
        {
          super()
          ()
        }
      def h(): Object = print()
    }
    new B(): Object
  }
  ()
} of class class dotty.tools.dotc.ast.Trees$Block # 264
exception while transforming def <init>(): Unit =
  {
    super()
    {
      private class B extends Object {
        def <init>(): Unit =
          {
            super()
            ()
          }
        def h(): Object = print()
      }
      new B(): Object
    }
    ()
  } of class class dotty.tools.dotc.ast.Trees$DefDef # 265
exception while transforming  extends Object {
  def <init>(): Unit =
    {
      super()
      {
        private class B extends Object {
          def <init>(): Unit =
            {
              super()
              ()
            }
          def h(): Object = print()
        }
        new B(): Object
      }
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$Template # 266
exception while transforming private class A extends Object {
  def <init>(): Unit =
    {
      super()
      {
        private class B extends Object {
          def <init>(): Unit =
            {
              super()
              ()
            }
          def h(): Object = print()
        }
        new B(): Object
      }
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 267
exception while transforming {
  private def print(): Object = x
  private class A extends Object {
    def <init>(): Unit =
      {
        super()
        {
          private class B extends Object {
            def <init>(): Unit =
              {
                super()
                ()
              }
            def h(): Object = print()
          }
          new B(): Object
        }
        ()
      }
  }
  ()
} of class class dotty.tools.dotc.ast.Trees$Block # 268
exception while transforming def f(x: Object): Unit =
  {
    private def print(): Object = x
    private class A extends Object {
      def <init>(): Unit =
        {
          super()
          {
            private class B extends Object {
              def <init>(): Unit =
                {
                  super()
                  ()
                }
              def h(): Object = print()
            }
            new B(): Object
          }
          ()
        }
    }
    ()
  } of class class dotty.tools.dotc.ast.Trees$DefDef # 269
exception while transforming  extends Object {
  def <init>(): Unit =
    {
      super()
      ()
    }
  def f(x: Object): Unit =
    {
      private def print(): Object = x
      private class A extends Object {
        def <init>(): Unit =
          {
            super()
            {
              private class B extends Object {
                def <init>(): Unit =
                  {
                    super()
                    ()
                  }
                def h(): Object = print()
              }
              new B(): Object
            }
            ()
          }
      }
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$Template # 280
exception while transforming @scala.annotation.internal.SourceFile("abc.scala") final module class test$ extends Object {
  def <init>(): Unit =
    {
      super()
      ()
    }
  def f(x: Object): Unit =
    {
      private def print(): Object = x
      private class A extends Object {
        def <init>(): Unit =
          {
            super()
            {
              private class B extends Object {
                def <init>(): Unit =
                  {
                    super()
                    ()
                  }
                def h(): Object = print()
              }
              new B(): Object
            }
            ()
          }
      }
      ()
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 281
exception while transforming package <empty> {
  final lazy module val test: test$ = new test$()
  @scala.annotation.internal.SourceFile("abc.scala") final module class test$ extends Object {
    def <init>(): Unit =
      {
        super()
        ()
      }
    def f(x: Object): Unit =
      {
        def print(): Object = x
        class A extends Object {
          def <init>(): Unit =
            {
              super()
              {
                class B extends Object {
                  def <init>(): Unit =
                    {
                      super()
                      ()
                    }
                  def h(): Object = print()
                }
                new B(): Object
              }
              ()
            }
        }
        ()
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 282

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: failure to construct path from method h/class B/class A/object test/package <empty>/package <root> to `this` of class A in object test;
class B in class A does not have an outer accessor
        at scala.Predef$.assert(Predef.scala:165)
        at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.loop$1(ExplicitOuter.scala:337)
        at dotty.tools.dotc.transform.ExplicitOuter$OuterOps$.path$extension(ExplicitOuter.scala:343)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter.memberRef(LambdaLift.scala:446)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter.dotty$tools$dotc$transform$LambdaLift$LambdaLifter$$proxyRef(LambdaLift.scala:452)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter$$anonfun$addFreeArgs$1.apply(LambdaLift.scala:457)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter$$anonfun$addFreeArgs$1.apply(LambdaLift.scala:457)
        at scala.collection.immutable.List.map(List.scala:273)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter.addFreeArgs(LambdaLift.scala:457)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter.transformApply(LambdaLift.scala:518)
        at dotty.tools.dotc.transform.LambdaLift$LambdaLifter.transformApply(LambdaLift.scala:77)
<snipped>
@odersky odersky self-assigned this Nov 6, 2016
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 10, 2016
We forgot the case where a hoistable method can still
refer to free variables that have to be passed using
outer pointers.

Fixes scala#1664.
DarkDimius added a commit that referenced this issue Nov 16, 2016
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

4 participants