diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-12 12:55:39 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-14 13:29:48 +0200 |
commit | f4a722d20547a5b4ffe47405d122b34b586c17c3 (patch) | |
tree | 513b54a5738fbe2d93596461f706eb14f696f404 /test/files/neg | |
parent | 524c90d09f2fb4687b312f2c7597393978d50b6a (diff) | |
download | scala-f4a722d20547a5b4ffe47405d122b34b586c17c3.tar.gz scala-f4a722d20547a5b4ffe47405d122b34b586c17c3.tar.bz2 scala-f4a722d20547a5b4ffe47405d122b34b586c17c3.zip |
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.
Diffstat (limited to 'test/files/neg')
14 files changed, 28 insertions, 28 deletions
diff --git a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala index c8567be5d4..5d88c90ffd 100644 --- a/test/files/neg/interop_abstypetags_arenot_classmanifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_classmanifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotClassManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotClassManifest[T: WeakTypeTag] = { println(classManifest[T]) } - absTypeTagIsnotClassManifest[Int] - absTypeTagIsnotClassManifest[String] - absTypeTagIsnotClassManifest[Array[Int]] + weakTypeTagIsnotClassManifest[Int] + weakTypeTagIsnotClassManifest[String] + weakTypeTagIsnotClassManifest[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_classtags.scala b/test/files/neg/interop_abstypetags_arenot_classtags.scala index e3911c1588..de1f8657b6 100644 --- a/test/files/neg/interop_abstypetags_arenot_classtags.scala +++ b/test/files/neg/interop_abstypetags_arenot_classtags.scala @@ -2,11 +2,11 @@ import scala.reflect.runtime.universe._ import scala.reflect.{ClassTag, classTag} object Test extends App { - def absTypeTagIsnotClassTag[T: AbsTypeTag] = { + def weakTypeTagIsnotClassTag[T: WeakTypeTag] = { println(classTag[T]) } - absTypeTagIsnotClassTag[Int] - absTypeTagIsnotClassTag[String] - absTypeTagIsnotClassTag[Array[Int]] + weakTypeTagIsnotClassTag[Int] + weakTypeTagIsnotClassTag[String] + weakTypeTagIsnotClassTag[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/interop_abstypetags_arenot_manifests.scala b/test/files/neg/interop_abstypetags_arenot_manifests.scala index 77a95048fd..1ca3673ce4 100644 --- a/test/files/neg/interop_abstypetags_arenot_manifests.scala +++ b/test/files/neg/interop_abstypetags_arenot_manifests.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ object Test extends App { - def absTypeTagIsnotManifest[T: AbsTypeTag] = { + def weakTypeTagIsnotManifest[T: WeakTypeTag] = { println(manifest[T]) } - absTypeTagIsnotManifest[Int] - absTypeTagIsnotManifest[String] - absTypeTagIsnotManifest[Array[Int]] + weakTypeTagIsnotManifest[Int] + weakTypeTagIsnotManifest[String] + weakTypeTagIsnotManifest[Array[Int]] }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index 5d42ebc515..eb5d833bc0 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,7 +1,7 @@ Macros_Test_1.scala:2: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context): c.Expr[Any]
found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal
-macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo[U] = macro Impls.foo[U]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala index 5aa9a7eaf9..c066c485b1 100644 --- a/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-context-bounds/Impls_1.scala @@ -2,7 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { + def foo[U: c.WeakTypeTag: Numeric](c: Ctx) = { import c.universe._ Literal(Constant(42)) } diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index 62156770e4..ca35e62cd7 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,7 +1,7 @@ Impls_Macros_1.scala:18: error: macro implementation has wrong shape:
required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit]
found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit]
-macro implementations cannot have implicit parameters other than AbsTypeTag evidences
+macro implementations cannot have implicit parameters other than WeakTypeTag evidences
def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala index f724538993..845a168ff2 100644 --- a/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-implicit-params/Impls_Macros_1.scala @@ -2,13 +2,13 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + def foo_targs[T, U: c.WeakTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ 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)))), - Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.AbsTypeTag[U]].tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe)))), Literal(Constant(()))) c.Expr[Unit](body) } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.check b/test/files/neg/macro-invalidsig-tparams-notparams-a.check index 5aee62b9e5..5404c185f3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[U])Nothing
+Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing
def foo = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala index afbe0f0915..f8b3c92869 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a/Impls_1.scala @@ -2,5 +2,5 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U: c.AbsTypeTag](c: Ctx) = ??? + def foo[U: c.WeakTypeTag](c: Ctx) = ??? }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.check b/test/files/neg/macro-invalidsig-tparams-notparams-b.check index e8de8a4c6b..485d4de96e 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo[V] = macro Impls.foo
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala index b48f9d5f98..baf3aab9e3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b/Impls_1.scala @@ -2,9 +2,9 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c.check b/test/files/neg/macro-invalidsig-tparams-notparams-c.check index b1078fb233..1530c35097 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.AbsTypeTag[T], implicit evidence$2: c.AbsTypeTag[U], implicit V: c.AbsTypeTag[V])c.Expr[Unit]
+Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
def foo[V] = macro Impls.foo[V]
^
one error found
diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala index 3506bdc789..44b4ed6ab3 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala +++ b/test/files/neg/macro-invalidsig-tparams-notparams-c/Impls_1.scala @@ -2,10 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[T: c.AbsTypeTag, U: c.AbsTypeTag, V](c: Ctx)(implicit V: c.AbsTypeTag[V]): c.Expr[Unit] = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Ctx)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ - println(implicitly[c.AbsTypeTag[T]]) - println(implicitly[c.AbsTypeTag[U]]) + println(implicitly[c.WeakTypeTag[T]]) + println(implicitly[c.WeakTypeTag[U]]) println(V) c.literalUnit } diff --git a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala index b66ad6c523..1e7fcb3f45 100644 --- a/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala +++ b/test/files/neg/macro-reify-typetag-useabstypetag/Test.scala @@ -1,7 +1,7 @@ import scala.reflect.runtime.universe._ object Test extends App { - def fooTypeTag[T: AbsTypeTag] = { + def fooTypeTag[T: WeakTypeTag] = { println(implicitly[TypeTag[T]]) println(implicitly[TypeTag[List[T]]]) } |