diff options
Diffstat (limited to 'tests/disabled/macro/run/macroPlugins-macroExpand')
5 files changed, 54 insertions, 0 deletions
diff --git a/tests/disabled/macro/run/macroPlugins-macroExpand/Macros_2.scala b/tests/disabled/macro/run/macroPlugins-macroExpand/Macros_2.scala new file mode 100644 index 000000000..c9c88ad2f --- /dev/null +++ b/tests/disabled/macro/run/macroPlugins-macroExpand/Macros_2.scala @@ -0,0 +1,18 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl1(c: Context) = { + import c.universe._ + q"""println("impl1")""" + } + + def impl2(c: Context) = { + import c.universe._ + q"""println("impl2")""" + } + + def foo1: Unit = macro impl1 + + def foo2: Unit = macro impl2 +}
\ No newline at end of file diff --git a/tests/disabled/macro/run/macroPlugins-macroExpand/Plugin_1.scala b/tests/disabled/macro/run/macroPlugins-macroExpand/Plugin_1.scala new file mode 100644 index 000000000..13df85cb2 --- /dev/null +++ b/tests/disabled/macro/run/macroPlugins-macroExpand/Plugin_1.scala @@ -0,0 +1,27 @@ +package macroExpand + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + import scala.reflect.internal.Mode + + val name = "macroExpand" + val description = "A sample analyzer plugin that overrides macroExpand." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + override def pluginsMacroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Option[Tree] = { + object expander extends DefMacroExpander(typer, expandee, mode, pt) { + override def onSuccess(expanded: Tree) = { + val message = s"expanded into ${expanded.toString}" + typer.typed(q"println($message)") + } + } + Some(expander(expandee)) + } + } +}
\ No newline at end of file diff --git a/tests/disabled/macro/run/macroPlugins-macroExpand/Test_3.flags b/tests/disabled/macro/run/macroPlugins-macroExpand/Test_3.flags new file mode 100644 index 000000000..966df731d --- /dev/null +++ b/tests/disabled/macro/run/macroPlugins-macroExpand/Test_3.flags @@ -0,0 +1 @@ +-Xplugin:.
\ No newline at end of file diff --git a/tests/disabled/macro/run/macroPlugins-macroExpand/Test_3.scala b/tests/disabled/macro/run/macroPlugins-macroExpand/Test_3.scala new file mode 100644 index 000000000..a730821f2 --- /dev/null +++ b/tests/disabled/macro/run/macroPlugins-macroExpand/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends dotty.runtime.LegacyApp { + Macros.foo1 + Macros.foo2 +}
\ No newline at end of file diff --git a/tests/disabled/macro/run/macroPlugins-macroExpand/scalac-plugin.xml b/tests/disabled/macro/run/macroPlugins-macroExpand/scalac-plugin.xml new file mode 100644 index 000000000..860150865 --- /dev/null +++ b/tests/disabled/macro/run/macroPlugins-macroExpand/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> + <name>macro-expand</name> + <classname>macroExpand.Plugin</classname> +</plugin>
\ No newline at end of file |