Scala macro modify object -


i have next macro annotation

 class foo(obj: string) extends staticannotation {     def macrotransform(annottees: any*) = macro macroimpl.impl  }   object macroimpl {     def impl(c: context)(annottees: c.expr[any]*): c.expr[any] = {       import c.universe._        // want find `obj` , modify body     }    }   // usage  @foo("pkg.myobject") class someclass {} 

is possible macro find object name , modify body of object?

this impossible, because macros in scala can't modify outside scope. e.g. def macros can rewrite applications, not code around, , macro annotations can rewrite annottees, not code around.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -