summaryrefslogtreecommitdiff
path: root/test/files/run/macro-impl-default-params
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-08-07 16:17:59 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-08-07 20:41:17 +0200
commit788478d3ab7dbb6386932eb8cb58dfcc5ee950b1 (patch)
treebe2c895415ababb27dfda7f533e6ce405125b0af /test/files/run/macro-impl-default-params
parentd8b35a11d67c2a597f1d93456b341a650b542520 (diff)
downloadscala-788478d3ab7dbb6386932eb8cb58dfcc5ee950b1.tar.gz
scala-788478d3ab7dbb6386932eb8cb58dfcc5ee950b1.tar.bz2
scala-788478d3ab7dbb6386932eb8cb58dfcc5ee950b1.zip
SI-6186 TypeTags no longer supported in macros
The original idea was to support both both TypeTags and ConcreteTypeTags as context bounds on macro implementations. Back then TypeTags were the implied default flavor of type tags. Basically because "TypeTag" is shorter than "ConcreteTypeTag" everyone jumped onto them and used them everywhere. That led to problems, because at that time TypeTags could reify unresolved type parameters ("unresolved" = not having TypeTag annotations for them). This led to a series of creepy errors, when one forgets to add a context bound in the middle of a chain of methods that all pass a type tag around, and then suddenly all the tags turn into pumpkins (because that unlucky method just reifies TypeRef(NoPrefix, <type parameter symbol>, Nil and passes it down the chain). Hence we decided to rename ConcreteTypeTag => TypeTag & TypeTag => AbsTypeTag, which makes a lot of sense from a reflection point of view. Unfortunately this broke macros (in a sense), because now everyone writes TypeTag context bounds on macro implementations, which breaks in trivial situations like: "def foo[T](x: T) = identity_macro(x)" (the type of x is not concrete, so macro expansion will emit an error when trying to materialize the corresponding TypeTag). Now we restore the broken balance by banning TypeTag from macro impls. This forces anyone to use AbsTypeTags, and if someone wants to check the input for presence of abstract types, it's possible to do that manually.
Diffstat (limited to 'test/files/run/macro-impl-default-params')
-rw-r--r--test/files/run/macro-impl-default-params/Impls_Macros_1.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
index 2ba28824e0..06c58d96ab 100644
--- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
+++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala
@@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._
import scala.reflect.macros.{Context => Ctx}
object Impls {
- def foo_targs[T, U: c.TypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = {
+ def foo_targs[T, U: c.AbsTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = {
import c.{prefix => prefix}
import c.universe._
- val U = implicitly[c.TypeTag[U]]
+ val U = implicitly[c.AbsTypeTag[U]]
val body = Block(
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))),
Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))),