Scala 推断类型参数

Scala 推断类型参数,scala,parameters,self-type,inferred-type,Scala,Parameters,Self Type,Inferred Type,为什么我在编译此代码段时出错 trait ID[R <: Record[R] with KeyedRecord[Long]] { this: R => val idField = new LongField(this) } trait ID[R] val idField=新朗菲尔德(本) } 错误: inferred type arguments [ID[R] with R] do not conform to class LongField's type param

为什么我在编译此代码段时出错

trait ID[R <: Record[R] with KeyedRecord[Long]] {

  this: R =>

  val idField = new LongField(this)
}
trait ID[R]
val idField=新朗菲尔德(本)
}
错误:

inferred type arguments [ID[R] with R] do not conform to class LongField's
type parameter bounds [OwnerType <: net.liftweb.record.Record[OwnerType]]
推断的类型参数[ID[R]和R]不符合LongField类的
类型参数边界[OwnerTypeConvert

val idField = new LongField(this)

如果未指定类型
R
,则LongField无法检查该类型是否为
记录[OwnerType]
的共同变体。明确提及该类型可以解决此问题

PS:我不知道需要重新确认的其他类声明,但以下声明有效:

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)
}
案例类记录[R]
类KeyedRecord[R]扩展记录[R]
类LongField[OwnerType
val idField = new LongField[R](this)
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)
}