Closed
Description
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>