trait GTT[T, S <: GTT[T,_] ] { this : S =>
def add(e: ATT[T]): S
def reverse: S
def toGColumns: Either[List[Throwable], S] = {
val tmp: (S, Int) = Tuple2[S,Int](this,1)
val rr: S = tmp._1
val r2 : S = rr.reverse
Right(r2)
}
}
Compiler states that:
found : _$1
[error] required: S
[error] val r2 : S = rr.reverse
rr has type S which is a subtype of GTT[T,_]. So the compiler doesn’t know which type rr.reverse returns (its type is _ …). He doesn’t know whether or not that type conforms to S.
Ok. I understand now. That is an error on my part. I should have declared:
trait GTT[T, S <: GTT[T,S] ] { this : S =>
I also understand why
Right(rr)
works. Compiler could not figure out what the “_” was but it knows it did not change (tuple returns the same type) - hence stays equal to the expected S.