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