Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25). Type in expressions to have them evaluated. Type :help for more information. scala> import language.experimental._ import language.experimental._ scala> import reflect.macros.blackbox.Context import reflect.macros.blackbox.Context scala> def macroImpl[T](c: Context)(implicit e: c.WeakTypeTag[T]): c.Expr[String] = { | import c.universe._ | c.Expr[String](q"${e.toString}") | } macroImpl: [T](c: scala.reflect.macros.blackbox.Context)(implicit e: c.WeakTypeTag[T])c.Expr[String] scala> def m = macro macroImpl[Seq[Int]] warning: there was one deprecation warning; re-run with -deprecation for details defined term macro m: String scala> m res3: String = WeakTypeTag[Seq[A]]
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25). Type in expressions to have them evaluated. Type :help for more information. scala> import language.experimental.macros import language.experimental.macros scala> import reflect.macros.Context import reflect.macros.Context scala> case class S[T](s: String) defined class S scala> def impl[T: c.WeakTypeTag](c: Context): c.Expr[S[T]] = {import c.universe._; c.Expr[S[T]](q"S[${weakTypeOf[T]}](${weakTypeOf[T].toString})")} warning: there was one deprecation warning; re-run with -deprecation for details impl: [T](c: reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T])c.Expr[S[T]] scala> implicit def m[T]: S[T] = macro impl[T] defined term macro m: [T]=> S[T] scala> m[Nothing] res0: S[Nothing] = S(Nothing) scala> implicitly[S[Nothing]](m) res1: S[Nothing] = S(T) scala> implicitly[S[Nothing]](m[Nothing]) res2: S[Nothing] = S(Nothing) scala>
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.