Note: the first example works. This shows what I want to get. The second example shows that I would like to declare it without a template, but could not do it.
I just want to get a simple thing:
trait SelfTest[T <: SelfTest[T]] {_ : T => def get : T = this } class Test extends SelfTest[Test] object Test extends Test
but without determining the class of the tile. Something like that:
trait SelfTest[T <: SelfTest[T]] {_ : T => def get : T = this } object Test extends SelfTest[Test.type]
But this method is rejected by scala ( illegal cyclic reference involving object Test ). Is there any magic like a # sign to indicate a created object?
source share