パラメーター化された型を指定すると、次のようになります。
trait Document[S]
これのインスタンスを埋め込みインタープリターにバインドしたい、例えば
def test[S](doc: Document[S]) = tools.nsc.interpreter.NamedParam("document", doc)
TypeTagこれはと のの両方が必要ClassTagですDocument[S]。Document[S]だけでなく、完全なタイプをバインドできる必要があることに注意してくださいDocument[_]。
これについてどうすればいいですか?ドキュメントに何かを追加すると思います。
trait Document[S] {
def tt: reflect.runtime.universe.TypeTag[Document[S]] = ???
def ct: reflect.runtime.universe.ClassTag[Document[S]] = ???
}
(名前付きパラメーターを取得するために、なぜ 2 つの異なるタグが必要なのですか?)
EDIT:以下はそれをコンパイルします
trait Document[S] {
implicit def systemType: reflect.runtime.universe.TypeTag[S]
}
def test[S](doc: Document[S]) = {
import doc.systemType
tools.nsc.interpreter.NamedParam("document", doc)
}
Document[_]しかし、私はまだインタープリターでへのバインディングになってしまうので、型パラメーター toDocumentは失われますか?!