Convert
val idField = new LongField(this)
to
val idField = new LongField[R](this)
If you do not specify the type R
, then the LongField cannot check if the type is co-variant to Record[OwnerType]
or not. Explicitly mentioning it should solve the purpose.
PS: I do not know the other class declaration to re-confirm, but the below declaration works:
case class Record[R]
class KeyedRecord[R] extends Record[R]
class LongField[OwnerType <: Record[OwnerType]](rec: OwnerType)
trait ID[R <: Record[R] with KeyedRecord[Long]] {
this: R =>
val idField = new LongField[R](this)
}