【发布时间】:2019-09-13 12:34:18
【问题描述】:
我在 Scala 中有以下课程:
class A {
def doSomething() = ???
def doOtherThing() = ???
}
class B {
val a: A
// need to enhance the class with both two functions doSomething() and doOtherThing() that delegates to A
// def doSomething() = a.toDomething()
// def doOtherThing() = a.doOtherThing()
}
我需要一种在编译时增强类 B 的方法,该类 B 具有与 A 相同的函数签名,当在 B 上调用时,它只是委托给 A。
在 Scala 中有没有很好的方法来做到这一点?
谢谢。
【问题讨论】:
标签: scala scala-macros