我有以下课程:
abstract class Base {
type T
def myMethod: T
}
abstract class B extends Base {
type T <: String
}
abstract class C extends Base {
type T <: Int
}
现在,如果我这样写:
class Test{
self: B with C =>
// do sth with myMethod
}
myMethod将导致某某类型为Int。另一方面,如果我这样写:
class Test{
self: C with B =>
// do sth with myMethod
}
我将得到String类型。有人可以解释吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句