Closed
Description
object Test {
def main(args: Array[String]): Unit = {
import Foo._
foo
// but Foo.foo works fine
}
}
object Foo extends Bar {
inline def foo: Int = bar
}
class Bar {
def bar = 42
}
fails compilation with the following error
exception while typing val Foo$_this: Foo.type(Foo) = this of class class dotty.tools.dotc.ast.Trees$ValDef # 99
exception while typing /* inlined from Foo*/
{
val Foo$_this: Foo.type(Foo) = this
Foo$_this.bar
} of class class dotty.tools.dotc.ast.Trees$Inlined # 143
exception while typing {
/* inlined from Foo*/
{
val Foo$_this: Foo.type(Foo) = this
Foo$_this.bar
}
()
} of class class dotty.tools.dotc.ast.Trees$Block # 178
exception while typing {
{
/* inlined from Foo*/
{
val Foo$_this: Foo.type(Foo) = this
Foo$_this.bar
}
()
}
} of class class dotty.tools.dotc.ast.Trees$Block # 179
exception while typing def main(args: Array[String]): Unit =
{
{
/* inlined from Foo*/
{
val Foo$_this: Foo.type(Foo) = this
Foo$_this.bar
}
()
}
} of class class dotty.tools.dotc.ast.Trees$DefDef # 180
exception while typing @scala.annotation.internal.SourceFile("/Users/nicolasstucki/GitHub/dotty/compiler/../tests/run/inline-foo.scala")
final module
class Test() extends Object() {
def main(args: Array[String]): Unit =
{
{
/* inlined from Foo*/
{
val Foo$_this: Foo.type(Foo) = this
Foo$_this.bar
}
()
}
}
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 183
exception while typing package <empty> {
final lazy module val Test: Test = new Test()
@scala.annotation.internal.SourceFile("/Users/nicolasstucki/GitHub/dotty/compiler/../tests/run/inline-foo.scala")
final module
class Test() extends Object() {
def main(args: Array[String]): Unit =
{
{
/* inlined from Foo*/
{
val Foo$_this: Foo.type(Foo) = this
Foo$_this.bar
}
()
}
}
}
final lazy module val Foo: Foo = new Foo()
@scala.annotation.internal.SourceFile("/Users/nicolasstucki/GitHub/dotty/compiler/../tests/run/inline-foo.scala")
final module
class Foo() extends Bar() {
@Foo.bar inline def foo: Int = Foo.bar
}
@scala.annotation.internal.SourceFile("/Users/nicolasstucki/GitHub/dotty/compiler/../tests/run/inline-foo.scala")
class
Bar() extends Object() {
def bar: Int = 42
}
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 199
*** error while checking /Users/nicolasstucki/GitHub/dotty/compiler/../tests/run/inline-foo.scala after phase tailrec ***
It looks like the this
in val Foo$_this: Foo.type(Foo) = this
is taken as the local this
instead of the Foo
. I would expect val Foo$_this: Foo.type(Foo) = Foo
or some variant of that.