相关疑难解决方法(0)

如何在Scala编译器插件中添加新类?

在Scala编译器插件中,我正在尝试创建一个实现预先存在的特征的新类.到目前为止我的代码看起来像这样:

def trait2Impl(original: ClassDef, newName: String): ClassDef = {
    val impl = original.impl
    // Seems OK to have same self, but does not make sense to me ...
    val self = impl.self
    // TODO: implement methods ...
    val body = impl.body
    // We implement original
    val parents = original :: impl.parents
    val newImpl = treeCopy.Template(impl, parents, self, body)
    val name = newTypeName(newName)
    // We are a syntheic class, not a user-defined trait
    val mods = (original.mods | SYNTHETIC) &~ TRAIT …
Run Code Online (Sandbox Code Playgroud)

scala

36
推荐指数
1
解决办法
982
查看次数

标签 统计

scala ×1