2013-05-01 3 views
0

이 스 니펫을 컴파일하는 동안 오류가 발생하는 이유는 무엇입니까?유추 된 형식 인수

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

    this: R => 

    val idField = new LongField(this) 
} 

ERROR :

나는이 문제를 해결할 수있는 방법
inferred type arguments [ID[R] with R] do not conform to class LongField's 
type parameter bounds [OwnerType <: net.liftweb.record.Record[OwnerType]] 

?


LongField 정의 :이 유형 R을 지정하지 않으면

class LongField[OwnerType <: Record[OwnerType]](rec: OwnerType) 
    extends Field[Long, OwnerType] with MandatoryTypedField[Long] with LongTypedField { 

답변

1

변환은

val idField = new LongField(this) 

val idField = new LongField[R](this) 

는 다음 LongField는 일반 경우 확인할 수 없습니다 e는 Record[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) 
} 
관련 문제