Considering the following example:
trait Supe {
type Out <: Supe
def out: Out
}
class Reif1 extends Supe {
type Out = Reif1
override def out: Out = this
}
class Reif2 extends Supe {
type Out >: this.type <: Reif2
override def out: Out = this
}
class Reif1
should obviously work. as type Out
is reified and becomes a type alias
class Reif2
also works but seriously? type Out
only has upper/lower bound defined and the bound was not even tight enough: this.type
is a singleton type, and Reif2
is a class type. So what exactly would Out
look like if Reif2
got instantiated? Is it going to be this.type
? Or Reif2
? But the bigger question should be: why scalac 2.12/2.13 allows it be compiled?