scalacenter / tasty-query

Apache License 2.0
51 stars 11 forks source link

How to check if a Symbol has the override modifier ? #439

Closed alexishorner closed 5 months ago

alexishorner commented 6 months ago

Hi ! I am rewriting the ExtractAPI phase of dotty using TASTy Query and I need to query if a Symbol has the override modifier.

Here is what the original dotty source code looks like (available in full here):

def apiModifiers(sym: Symbol): api.Modifiers = {
  val absOver = sym.is(AbsOverride)
  val abs = absOver || sym.isOneOf(Trait | Abstract | Deferred)
  val over = absOver || sym.is(Override)
  new api.Modifiers(abs, over, [...])
}

My current solution boils down to doing

sym.flags.is(Override)

However, Symbol.flags is protected, so I invoke it using reflection, which does not seem like a great solution.

Does someone know a better way of checking if a Symbol has the override modifier ? Thanks in advance for your assistance !

bishabosha commented 5 months ago

advice from @sjrd - (in the context of incremental compilation) ignore the override flag altogether - its not information that could ever require a downstream recompilation

alexishorner commented 5 months ago

Got it, thanks !