diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/pos/t8801.scala | 21 | ||||
-rw-r--r-- | test/files/run/macroPlugins-enterStats.check | 30 | ||||
-rw-r--r-- | test/files/run/macroPlugins-enterStats.scala | 50 |
3 files changed, 101 insertions, 0 deletions
diff --git a/test/files/pos/t8801.scala b/test/files/pos/t8801.scala new file mode 100644 index 0000000000..695b456e12 --- /dev/null +++ b/test/files/pos/t8801.scala @@ -0,0 +1,21 @@ +sealed trait Nat { + type Prev <: Nat { type Succ = Nat.this.type } + type Succ <: Nat { type Prev = Nat.this.type } +} + +object Nat { + object Zero extends Nat { + type Prev = Nothing + } + + type _0 = Zero.type + type _1 = _0#Succ + type _2 = _1#Succ + type _3 = _2#Succ + type _4 = _3#Succ + type _5 = _4#Succ + type _6 = _5#Succ + type _7 = _6#Succ + type _8 = _7#Succ + type _9 = _8#Succ +} diff --git a/test/files/run/macroPlugins-enterStats.check b/test/files/run/macroPlugins-enterStats.check new file mode 100644 index 0000000000..133b1ae1af --- /dev/null +++ b/test/files/run/macroPlugins-enterStats.check @@ -0,0 +1,30 @@ +[[syntax trees at end of typer]] // newSource1.scala +package <empty> { + class C extends scala.AnyRef { + def <init>(): C = { + C.super.<init>(); + () + }; + def x: Int = 2; + def xmacroPlugin1: Nothing = scala.this.Predef.???; + def xmacroPlugin2: Nothing = scala.this.Predef.???; + def xmacroPlugin2macroPlugin1: Nothing = scala.this.Predef.???; + def y: Int = 3; + def ymacroPlugin1: Nothing = scala.this.Predef.???; + def ymacroPlugin2: Nothing = scala.this.Predef.???; + def ymacroPlugin2macroPlugin1: Nothing = scala.this.Predef.??? + } +} + +macroPlugin2:enterStat(class C extends scala.AnyRef { def <init>() = { super.<init>(); () }; def x = 2; def y = 3 }) +macroPlugin1:enterStat(class C extends scala.AnyRef { def <init>() = { super.<init>(); () }; def x = 2; def y = 3 }) +macroPlugin2:enterStat(def <init>() = { super.<init>(); () }) +macroPlugin2:enterStat(def x = 2) +macroPlugin2:enterStat(def y = 3) +macroPlugin1:enterStat(def <init>() = { super.<init>(); () }) +macroPlugin1:enterStat(def x = 2) +macroPlugin1:enterStat(def xmacroPlugin2 = $qmark$qmark$qmark) +macroPlugin1:enterStat(def y = 3) +macroPlugin1:enterStat(def ymacroPlugin2 = $qmark$qmark$qmark) +macroPlugin2:enterStat(super.<init>()) +macroPlugin1:enterStat(super.<init>()) diff --git a/test/files/run/macroPlugins-enterStats.scala b/test/files/run/macroPlugins-enterStats.scala new file mode 100644 index 0000000000..917233e990 --- /dev/null +++ b/test/files/run/macroPlugins-enterStats.scala @@ -0,0 +1,50 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp -Xprint:typer" + + def code = """ + class C { + def x = 2 + def y = 3 + } + """.trim + + def show() { + val global = newCompiler() + import global._ + import analyzer._ + + val output = collection.mutable.ListBuffer[String]() + def log(what: String) = output += what.replace(String.format("%n"), " ") + + def logEnterStat(pluginName: String, stat: Tree): Unit = log(s"$pluginName:enterStat($stat)") + def deriveStat(pluginName: String, typer: Typer, stat: Tree): List[Tree] = stat match { + case DefDef(mods, name, Nil, Nil, TypeTree(), body) => + val derived = DefDef(NoMods, TermName(name + pluginName), Nil, Nil, TypeTree(), Ident(TermName("$qmark$qmark$qmark"))) + newNamer(typer.context).enterSym(derived) + List(derived) + case _ => + Nil + } + + object macroPlugin1 extends MacroPlugin { + override def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = { + stats.foreach(stat => logEnterStat("macroPlugin1", stat)) + stats.flatMap(stat => stat +: deriveStat("macroPlugin1", typer, stat)) + } + } + object macroPlugin2 extends MacroPlugin { + override def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = { + stats.foreach(stat => logEnterStat("macroPlugin2", stat)) + stats.flatMap(stat => stat +: deriveStat("macroPlugin2", typer, stat)) + } + } + + addMacroPlugin(macroPlugin1) + addMacroPlugin(macroPlugin2) + compileString(global)(code) + println(output.mkString("\n")) + } +} |