diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-03-10 10:56:36 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-03-10 10:56:36 +0100 |
commit | 40b7832823d5e1cc39397b8960e62e0283bb0502 (patch) | |
tree | 3cdbd1e0a480d6258d9cb7a4017379ea03bbc86b /test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala | |
parent | 79ecd92f76df859cfde4b813ab9530d5352e48ca (diff) | |
parent | 384322b1cb824b0ff8a2a15a75d33d6a7cf8e85c (diff) | |
download | scala-40b7832823d5e1cc39397b8960e62e0283bb0502.tar.gz scala-40b7832823d5e1cc39397b8960e62e0283bb0502.tar.bz2 scala-40b7832823d5e1cc39397b8960e62e0283bb0502.zip |
Merge pull request #3606 from xeno-by/ticket/8375
SI-8375 saner binary incompat errors for macros
Diffstat (limited to 'test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala')
-rw-r--r-- | test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala b/test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala new file mode 100644 index 0000000000..44ed91d2fb --- /dev/null +++ b/test/files/neg/macro-incompatible-macro-engine-a/Plugin_1.scala @@ -0,0 +1,35 @@ +package incompatibleMacroEngine + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + + val name = "incompatibleMacroEngine" + val description = "A sample analyzer plugin that crafts a macro impl binding with a non-standard macro engine." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + def fixupBinding(tree: Tree) = new Transformer { + override def transform(tree: Tree) = { + tree match { + case Literal(const @ Constant(x)) if tree.tpe == null => tree setType ConstantType(const) + case _ if tree.tpe == null => tree setType NoType + case _ => ; + } + super.transform(tree) + } + }.transform(tree) + + override def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = { + val result = standardTypedMacroBody(typer, ddef) + val List(AnnotationInfo(atp, List(Apply(nucleus, _ :: others)), Nil)) = ddef.symbol.annotations + val updatedBinding = Apply(nucleus, Assign(Literal(Constant("macroEngine")), Literal(Constant("vxxx (implemented in the incompatibleMacroEngine plugin)"))) :: others) + ddef.symbol.setAnnotations(List(AnnotationInfo(atp, List(fixupBinding(updatedBinding)), Nil))) + Some(result) + } + } +}
\ No newline at end of file |