This page is no longer maintained — Please continue to the home page at www.scala-lang.org

this.type strangeness

No replies
Stepan Koltsov
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.

Hi, all:

===
class A {
def b(): this.type = {
val r = this
r
}
}
===

Fails to compile: found : r.type (with underlying type A) required:
A.this.type. Is it a bug, or I don't understand how this.type work?

I know workaround:

===
class A {
def b(): this.type = {
val r: this.type = this
r
}
}
===

S.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland