I frequently come across a problem where I need a member in an implementation of an abstract class to indicate it will return the concrete type. I'm sure I'm missing something obvious here.
This is a trivial example that indicates the problem:
object Poop {
def getValue[T <: Poop](x: T): T = x.aValue
}
abstract class Poop {
val aValue: Poop
}
This fails to compile the x.aValue expression with "Expression of type Poop doesn't conform to expected type T", obviously because the compiler doesn't know what the real type of aValue will be.
How do define my abstract class so the aValue will be the concrete type? Or should I be modelling problems like this differently?