-
-
Save takezoe/2519721 to your computer and use it in GitHub Desktop.
not var macro scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def NotVar(expr: Any): Any = macro NotVarImpl | |
def NotVarImpl(c: Context)(expr: c.Expr[Any]): c.Expr[Any] = { | |
import c.mirror._ | |
import reflect.api.Modifier.mutable | |
Expr((new Transformer{ | |
override def transform(tree:Tree):Tree = tree match{ | |
case ValDef(m,_,_,_) if m.hasModifier(mutable) => sys.error("can't use var !!!") | |
case _ => super.transform(tree) | |
} | |
}).transform(expr.tree)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2.10 M3で動くように修正してみた。