如何回调超级类Scala

时间:2018-06-06 17:50:38

标签: scala

我有两个特点:

trait ThingA[B, A <: OtherThingA[B]] extends ExtendedThing[B, A] {
  def ImportantButNotSharedLogicThing =
    "Something different"
}

trait ThingB[B, A <: OtherThingA[B]] extends ExtendedThing[B, A] {
  def ImportantButNotSharedLogicThing =
    "Something different again"
}

ExtendedThing

中的此方法
trait ExtendedThing[B, A <: OtherThing[B]] {
   <lots of shared logic>

   <even more shared logic>
    def apply(): A = 
       ImportantButNotSharedLogicThing()
}

如果我有一个扩展ThingA的对象

object Someobject extends ThingA

apply

最终会调用SmartsOrderWriter()方法

ExtendedThing特征,我如何调用ThingAThingB中定义的方法(对于扩展ThingB的对象

0 个答案:

没有答案