3
我不知道,如果你能写的东西像斯卡拉如下:是否有像抽象类型那样的参数化类型的清单?
abstract class Foo
trait Bar {
type Foo_Tpe <: Foo : Manifest[Foo_Tpe]
def fooClass = classOf[Foo_Tpe]
}
我不知道,如果你能写的东西像斯卡拉如下:是否有像抽象类型那样的参数化类型的清单?
abstract class Foo
trait Bar {
type Foo_Tpe <: Foo : Manifest[Foo_Tpe]
def fooClass = classOf[Foo_Tpe]
}
没有,但你可以问一个子类,以使其:
trait Bar {
type Foo_Tpe <: Foo
protected def fooManifest: Manifest[Foo_Tpe]
def fooClass = fooManifest.erasure
}
是,也不是。你可以这样做:
val man = manifest[Foo_Tpe]
在这一点上它会告诉你它没有一个清单。
我想有一个由Scala编译器提供的,而不是由一个亚型定义。 – 2012-01-28 13:56:25
你不能从'Bar'中编译器提供它。 – 2012-01-28 16:16:21