是否可以重命名来自基类的Scala方法?

| 我是Scala的新手,我正在尝试在Lift中使用lift-squeryl-record。 Scala是2.8.1,Lift是2.3。我的问题是我想使用Record中的(Mega)ProtoUser,但它与lift-squeryl-record冲突。 我遵循以下指示: lift-squeryl-record示例 并没有使用ProtoUser,而是试图这样定义我的用户:
trait AbstractUser[MyType <: AbstractUser[MyType]] extends
ProtoUser[MyType] with Record[MyType] with KeyedRecord[Long] {
注意:KeyedRecord来自包net.liftweb.squerylrecord,而不是net.liftweb.record 然后我得到以下错误:
overriding lazy value id in trait ProtoUser of type net.liftweb.record.field.LongField[MyType];  method id in trait KeyedRecord of type => Long needs
override\'修饰符` 因为KeyedRecord和ProtoUser都定义了不同的id方法。由于我不控制这两个类/特征的代码,因此是否有“ Scala”方式,如重命名方法之一?我真的不想在两者之间进行选择。 :(     
已邀请:
不,您不能重命名子类中的方法。如果父类型有两个相互矛盾的方法签名,则需要使用其他模式,例如通过委派进行间接访问(http://en.wikipedia.org/wiki/Delegation_pattern)
trait AbstractUser[MyType <: AbstractUser[MyType]] extends ProtoUser[MyType] {
   def record: Record[MyType] with KeyedRecord[Long]
}
    

要回复问题请先登录注册