While I split my head over another question , I came across different puzzles that seem to be related. This is one of them:
trait Sys[S <: Sys[S]] { type Peer <: Sys[Peer] } trait Fenced { type Peer <: Sys[Peer] } def makeFence[S <: Sys[S]] = new Fenced { type Peer = S
If the error is this:
error: overriding type Peer in trait Fenced with bounds >: Nothing <: Sys[this.Peer]; type Peer has incompatible type def makeFence[S <: Sys[S]] = new Fenced { type Peer = S
Why? (also tried to add _:S => self-tuning to Sys , it didn't matter)
While the Rex answer allows you to build a Fenced object, it really does not solve the problems that I have when a representation type character is lost when using a type projection ( S#Peer ). I came up with another scenario that creates more stringent restrictions; I think this is the main problem:
trait Test[S <: Sys[S]] { def make[T <: Sys[T]](): Unit make[S#Peer]() } error: type arguments [S#Peer] do not conform to method make type parameter bounds [T <: Sys[T]] make[S#Peer]() ^
types scala abstract-type type-projection
0__
source share