【发布时间】:2012-02-28 16:12:40
【问题描述】:
我要做的是创建一个函数,该函数将采用泛型类并在其中使用静态方法(对不起,Java 语言,我的意思是它的伴随对象的方法)。
trait Worker {def doSth: Unit}
class Base
object Base extends Worker
// this actually wouldn't work, just to show what I'm trying to achieve
def callSthStatic[T that companion object is <: Worker](implicit m: Manifest[T]) {
// here I want to call T.doSth (on T object)
m.getMagicallyCompanionObject.doSth
}
有什么想法吗?
【问题讨论】:
标签: class scala object types implicit