From f4a722d20547a5b4ffe47405d122b34b586c17c3 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 12 Sep 2012 12:55:39 +0200 Subject: SI-6310 AbsTypeTag => WeakTypeTag The new name for AbsTypeTag was a matter of a lengthy discussion: http://groups.google.com/group/scala-internals/browse_thread/thread/fb2007e61b505c4d I couldn't decide until having fixed SI-6323 today, which is about trying to reflect against a local class using typeOf. The problem with local classes is that they aren't pickled, so their metadata isn't preserved between Scala compilation runs. Sure, we can restore some of that metadata with Java reflection, but you get the idea. Before today typeOf of a local class created a free type, a synthetic symbol, with a bunch of synthetic children that remember the metadata, effectively creating a mini symbol table. That might be useful at time, but the problem is that this free type cannot be reflected, because the global symbol table of Scala reflection doesn't know about its mini symbol table. And then it struck me. It's not the presence of abs types (type parameters and abs type members) that differentiates arbitrary type tags from good type tags. It's the presence of types that don't map well on the runtime world - ones that can't be used to instantiate values, ones that can't be reflected. So we just need a name for these types. Phantom types are compile-time only concept, whereas our types can have partial correspondence with the runtime. "Weak types" sound more or less okish, so let's try them out. --- .../macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala | 2 +- test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala | 4 ++-- test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala | 4 ++-- test/pending/run/macro-reify-array/Macros_1.scala | 2 +- test/pending/run/macro-reify-tagful-b/Macros_1.scala | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'test/pending') diff --git a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala index 26d4a45fee..15bcb581c8 100644 --- a/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala +++ b/test/pending/run/macro-expand-implicit-macro-defeats-type-inference/Impls_1.scala @@ -1,7 +1,7 @@ import scala.reflect.macros.Context object Impls { - def foo[T: c.AbsTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Context): c.Expr[List[T]] = c.universe.reify { println("openImplicits are: " + c.literal(c.openImplicits.toString).splice) println("enclosingImplicits are: " + c.literal(c.enclosingImplicits.toString).splice) println("typetag is: " + c.literal(c.tag[T].toString).splice) diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala index d6ebb907e5..26de70cc12 100644 --- a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala index d6ebb907e5..26de70cc12 100644 --- a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala +++ b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala @@ -1,11 +1,11 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T, U: c.AbsTypeTag, V](c: Ctx)(implicit T: c.AbsTypeTag[T], V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Ctx)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ Block(List( Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.AbsTypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), Literal(Constant(()))) } diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala index 99006c548a..f970be5caa 100644 --- a/test/pending/run/macro-reify-array/Macros_1.scala +++ b/test/pending/run/macro-reify-array/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: String) = macro Impls.foo[T] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { Array(s.splice) } } diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala index a14187e8a7..59dbe7157b 100644 --- a/test/pending/run/macro-reify-tagful-b/Macros_1.scala +++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def foo[T](s: T) = macro Impls.foo[List[T]] object Impls { - def foo[T: c.AbsTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } -- cgit v1.2.3