您应该为其多引入一个类型参数
compilerLikey
写下
JsonOps
trait JsonOps[J] {
type ObjectFields
def partitionObjectFields(fields: ObjectFields, fieldNames: List[String]): (ObjectFields, ObjectFields)
}
def compilerLikey[J, OF](stuff: OF)(implicit ops: JsonOps[J] { type ObjectFields = OF }) = {}
或使用
Aux-pattern
trait JsonOps[J] {
type ObjectFields
def partitionObjectFields(fields: ObjectFields, fieldNames: List[String]): (ObjectFields, ObjectFields)
}
object JsonOps {
type Aux[J, OF] = JsonOps[J] { type ObjectFields = OF }
}
def compilerLikey[J, OF](stuff: OF)(implicit ops: JsonOps.Aux[J, OF]) = {}