Question

While doing DSL stuff, I'd like to add several aliases to an existing macro annotation and, if possible, I'd like to avoid typing the macroTransform definition. That is to say that I want to declare an alias for the "macro header", instead of the macro implementation.

I've been doing some unsuccessful attempts. For instance, given the original annotation header,

class original extends StaticAnnotation {
  def macroTransform(annottees: Any*) = macro originalImpl
}

I tried to make an alias by using a type alias:

type alias1 = original
@alias1 trait Whatever

Besides, I deployed an inheriting annotation version:

class alias2 extends original
@alias2 trait Whatever

However, none of them expand. Is there any convenient way to do so?

Was it helpful?

Solution

So far that's impossible, because the typechecker uses a very restricted name resolution algorithm to figure out whether a given identifier refers to a macro annotation. Within the restrictions of this algorithm, it's unfortunately impossible to dealias. I've created a bug report at https://github.com/scalamacros/paradise/issues/8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top