aboutsummaryrefslogtreecommitdiff
path: root/tests/disabled/macro/run/toolbox_current_run_compiles.scala
blob: 702741c2e668d0e993046e1a4fe0bbd16260184e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package pkg {
  import scala.reflect.macros.blackbox.Context
  import scala.language.experimental.macros

  object Macros {
    def impl[T: c.WeakTypeTag](c: Context) = {
      import c.universe._
      val sym = c.weakTypeOf[T].typeSymbol
      val g = c.universe.asInstanceOf[scala.tools.nsc.Global]
      c.Expr[Boolean](Literal(Constant(g.currentRun.compiles(sym.asInstanceOf[g.Symbol]))))
    }
    def compiles[T]: Boolean = macro impl[T]
  }
}

import scala.reflect.runtime.universe._
import scala.reflect.runtime.{universe => ru}
import scala.tools.reflect.ToolBox

object Test extends dotty.runtime.LegacyApp {
  val cm = ru.runtimeMirror(getClass.getClassLoader)
  val toolbox = cm.mkToolBox()
  toolbox.eval(toolbox.parse("""{
    class C
    println(pkg.Macros.compiles[C])
    println(pkg.Macros.compiles[Object])
  }"""))
}