Scala Compiler Plugin - Determine whether method is overridden
I am writing a Scala Compiler Plugin with a component the executes after the "jvm" phase where there is need to know that a method is overridden. Here is a distilled version of a test case I am working on:
abstract class GenericController[T] {
def getPath():String
def save(entity:T):String = "parent"
}
class StatusController extends GenericController[String] {
override def getPath():String = "/statuses"
override def save(entity:String):String = "child"
}
When traversing the AST, I iterate over the classes and the methods ensuring that I only process the methods that are not overridden. The scala.reflect.internal.Symbols.MethodSymbol.overrides()
method applied to the symbol for the StatusController.getPath
method will include the one for GenericController.getPath
.
However, the MethodSymbol.overrides()
fails to return the GenericController.save
method for the StatusController.save
symbol. Seem like the generic type complicates this behavior, Should this be done after another compiler phase?
from Recent Questions - Stack Overflow https://ift.tt/35GMuJC
https://ift.tt/eA8V8J
Comments
Post a Comment