I'm writing a Scala compiler plugin for the refchecks phase.
How do I access the symbol that a "super" call refers to, given the symbol of the callsite?
For example, in
trait A {
def m() {}
}
trait B extends A {
def m() { super.m() }
}
knowing the symbol for the callsite super.m()
, I would like to get the symbol for trait A
.
I think using of self type annotations and multiple inheritance will serve you:
trait HelperTrait {
def helperMethod {println("calling helperMethod of HelperTrait")}
}
trait PublicInterface { this: HelperTrait =>
def useHelperMethod
{
println("calling useHelperMethod of PublicInterface")
helperMethod
}
}
class ImplementationClass extends PublicInterface with HelperTrait
var obj = new ImplementationClass()
obj.useHelperMethod
obj.helperMethod
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With