Compiler plugin, if/else from match statement

Hi,

Is there a way to easily convert a match statement in the AST in a compiler plugin into an if/else statement?
I think one of the compiler phases (the pattern matching phase) is supposed to do this and my phase should be after that one yet the match statements are still only recognised by the match statement quasiquote and the raw tree is a Match().
Here is my phase statement:
val runsAfter: List[String] = List[String]("refchecks")

Well there’s the issue probably.

In scala 2.13.3 at least, patmat also runs after refchecks:

  object patmat extends {
    val global: Global.this.type = Global.this
    // patmat does not need to run before the superaccessors phase, because
    // patmat never emits `this.x` where `x` is a ParamAccessor.
    // (However, patmat does need to run before outer accessors generation).
    val runsAfter = List("refchecks")
    val runsRightAfter = None
  } with PatternMatching

So currently it’s not guaranteed that your plugin will run after the patmat phase.

2 Likes