diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-04 23:25:11 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-04 23:25:11 -0700 |
commit | b9371a739a6ac0399fece24ba202a2c9f40e3cc8 (patch) | |
tree | 893e2aa779e160556f74bddca3e049ac2a27af42 | |
parent | cae38dc68d02ac5fa80e2d8994990499dc63e657 (diff) | |
parent | fb5a2ff10e1e40f3c8408c52617f870cab758a61 (diff) | |
download | scala-b9371a739a6ac0399fece24ba202a2c9f40e3cc8.tar.gz scala-b9371a739a6ac0399fece24ba202a2c9f40e3cc8.tar.bz2 scala-b9371a739a6ac0399fece24ba202a2c9f40e3cc8.zip |
Merge pull request #818 from scalamacros/topic/tags-for-anyval-and-anyref
tags for AnyVal and AnyRef
-rw-r--r-- | src/compiler/scala/reflect/reify/Taggers.scala | 2 | ||||
-rw-r--r-- | src/library/scala/reflect/ClassTag.scala | 4 | ||||
-rw-r--r-- | src/library/scala/reflect/base/TypeTags.scala | 8 | ||||
-rw-r--r-- | test/files/run/abstypetags_core.check | 56 | ||||
-rw-r--r-- | test/files/run/abstypetags_core.scala | 4 | ||||
-rw-r--r-- | test/files/run/classtags_core.check | 4 | ||||
-rw-r--r-- | test/files/run/classtags_core.scala | 4 | ||||
-rw-r--r-- | test/files/run/typetags_core.check | 56 | ||||
-rw-r--r-- | test/files/run/typetags_core.scala | 4 |
9 files changed, 88 insertions, 54 deletions
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index e4c3d02f22..e09f13a052 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -21,6 +21,8 @@ abstract class Taggers { BooleanTpe -> nme.Boolean, UnitTpe -> nme.Unit, AnyTpe -> nme.Any, + AnyValTpe -> nme.AnyVal, + AnyRefTpe -> nme.AnyRef, ObjectTpe -> nme.Object, NothingTpe -> nme.Nothing, NullTpe -> nme.Null) diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 8d7b0858ef..5255c44f10 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -79,8 +79,8 @@ object ClassTag { val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit]{ def runtimeClass = java.lang.Void.TYPE; private def readResolve() = ClassTag.Unit } val Any : ClassTag[scala.Any] = new ClassTag[scala.Any]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Any } val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object } - val AnyVal : ClassTag[scala.AnyVal] = new ClassTag[scala.AnyVal]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyVal } - val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyRef } + val AnyVal : ClassTag[scala.AnyVal] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyVal]] + val AnyRef : ClassTag[scala.AnyRef] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyRef]] val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing } val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null } diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index 1906118ed1..05b1a079d7 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -134,6 +134,8 @@ trait TypeTags { self: Universe => val Boolean : AbsTypeTag[scala.Boolean] = TypeTag.Boolean val Unit : AbsTypeTag[scala.Unit] = TypeTag.Unit val Any : AbsTypeTag[scala.Any] = TypeTag.Any + val AnyVal : AbsTypeTag[scala.AnyVal] = TypeTag.AnyVal + val AnyRef : AbsTypeTag[scala.AnyRef] = TypeTag.AnyRef val Object : AbsTypeTag[java.lang.Object] = TypeTag.Object val Nothing : AbsTypeTag[scala.Nothing] = TypeTag.Nothing val Null : AbsTypeTag[scala.Null] = TypeTag.Null @@ -150,6 +152,8 @@ trait TypeTags { self: Universe => case BooleanTpe => AbsTypeTag.Boolean.asInstanceOf[AbsTypeTag[T]] case UnitTpe => AbsTypeTag.Unit.asInstanceOf[AbsTypeTag[T]] case AnyTpe => AbsTypeTag.Any.asInstanceOf[AbsTypeTag[T]] + case AnyValTpe => AbsTypeTag.AnyVal.asInstanceOf[AbsTypeTag[T]] + case AnyRefTpe => AbsTypeTag.AnyRef.asInstanceOf[AbsTypeTag[T]] case ObjectTpe => AbsTypeTag.Object.asInstanceOf[AbsTypeTag[T]] case NothingTpe => AbsTypeTag.Nothing.asInstanceOf[AbsTypeTag[T]] case NullTpe => AbsTypeTag.Null.asInstanceOf[AbsTypeTag[T]] @@ -195,6 +199,8 @@ trait TypeTags { self: Universe => val Boolean: TypeTag[scala.Boolean] = new PredefTypeTag[scala.Boolean] (BooleanTpe, _.TypeTag.Boolean) val Unit: TypeTag[scala.Unit] = new PredefTypeTag[scala.Unit] (UnitTpe, _.TypeTag.Unit) val Any: TypeTag[scala.Any] = new PredefTypeTag[scala.Any] (AnyTpe, _.TypeTag.Any) + val AnyVal: TypeTag[scala.AnyVal] = new PredefTypeTag[scala.AnyVal] (AnyValTpe, _.TypeTag.AnyVal) + val AnyRef: TypeTag[scala.AnyRef] = new PredefTypeTag[scala.AnyRef] (AnyRefTpe, _.TypeTag.AnyRef) val Object: TypeTag[java.lang.Object] = new PredefTypeTag[java.lang.Object] (ObjectTpe, _.TypeTag.Object) val Nothing: TypeTag[scala.Nothing] = new PredefTypeTag[scala.Nothing] (NothingTpe, _.TypeTag.Nothing) val Null: TypeTag[scala.Null] = new PredefTypeTag[scala.Null] (NullTpe, _.TypeTag.Null) @@ -211,6 +217,8 @@ trait TypeTags { self: Universe => case BooleanTpe => TypeTag.Boolean.asInstanceOf[TypeTag[T]] case UnitTpe => TypeTag.Unit.asInstanceOf[TypeTag[T]] case AnyTpe => TypeTag.Any.asInstanceOf[TypeTag[T]] + case AnyValTpe => TypeTag.AnyVal.asInstanceOf[TypeTag[T]] + case AnyRefTpe => TypeTag.AnyRef.asInstanceOf[TypeTag[T]] case ObjectTpe => TypeTag.Object.asInstanceOf[TypeTag[T]] case NothingTpe => TypeTag.Nothing.asInstanceOf[TypeTag[T]] case NullTpe => TypeTag.Null.asInstanceOf[TypeTag[T]] diff --git a/test/files/run/abstypetags_core.check b/test/files/run/abstypetags_core.check index ec93221a30..8d20e099c4 100644 --- a/test/files/run/abstypetags_core.check +++ b/test/files/run/abstypetags_core.check @@ -1,26 +1,30 @@ -true -TypeTag[Byte] -true -TypeTag[Short] -true -TypeTag[Char] -true -TypeTag[Int] -true -TypeTag[Long] -true -TypeTag[Float] -true -TypeTag[Double] -true -TypeTag[Boolean] -true -TypeTag[Unit] -true -TypeTag[Any] -true -TypeTag[java.lang.Object] -true -TypeTag[Null] -true -TypeTag[Nothing] +true
+TypeTag[Byte]
+true
+TypeTag[Short]
+true
+TypeTag[Char]
+true
+TypeTag[Int]
+true
+TypeTag[Long]
+true
+TypeTag[Float]
+true
+TypeTag[Double]
+true
+TypeTag[Boolean]
+true
+TypeTag[Unit]
+true
+TypeTag[Any]
+true
+TypeTag[AnyVal]
+true
+TypeTag[AnyRef]
+true
+TypeTag[java.lang.Object]
+true
+TypeTag[Null]
+true
+TypeTag[Nothing]
diff --git a/test/files/run/abstypetags_core.scala b/test/files/run/abstypetags_core.scala index dbe9b5e11d..226de94055 100644 --- a/test/files/run/abstypetags_core.scala +++ b/test/files/run/abstypetags_core.scala @@ -21,6 +21,10 @@ object Test extends App { println(implicitly[AbsTypeTag[Unit]]) println(implicitly[AbsTypeTag[Any]] eq AbsTypeTag.Any) println(implicitly[AbsTypeTag[Any]]) + println(implicitly[AbsTypeTag[AnyVal]] eq AbsTypeTag.AnyVal) + println(implicitly[AbsTypeTag[AnyVal]]) + println(implicitly[AbsTypeTag[AnyRef]] eq AbsTypeTag.AnyRef) + println(implicitly[AbsTypeTag[AnyRef]]) println(implicitly[AbsTypeTag[Object]] eq AbsTypeTag.Object) println(implicitly[AbsTypeTag[Object]]) println(implicitly[AbsTypeTag[Null]] eq AbsTypeTag.Null) diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index ce7793e188..6519db2178 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -21,6 +21,10 @@ ClassTag[class java.lang.Object] true
ClassTag[class java.lang.Object]
true
+ClassTag[class java.lang.Object]
+true
+ClassTag[class java.lang.Object]
+true
ClassTag[class scala.runtime.Null$]
true
ClassTag[class scala.runtime.Nothing$]
diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala index ad5e12a8c2..0e174d8243 100644 --- a/test/files/run/classtags_core.scala +++ b/test/files/run/classtags_core.scala @@ -21,6 +21,10 @@ object Test extends App { println(implicitly[ClassTag[Unit]]) println(implicitly[ClassTag[Any]] eq ClassTag.Any) println(implicitly[ClassTag[Any]]) + println(implicitly[ClassTag[AnyVal]] eq ClassTag.AnyVal) + println(implicitly[ClassTag[AnyVal]]) + println(implicitly[ClassTag[AnyRef]] eq ClassTag.AnyRef) + println(implicitly[ClassTag[AnyRef]]) println(implicitly[ClassTag[Object]] eq ClassTag.Object) println(implicitly[ClassTag[Object]]) println(implicitly[ClassTag[Null]] eq ClassTag.Null) diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check index ec93221a30..8d20e099c4 100644 --- a/test/files/run/typetags_core.check +++ b/test/files/run/typetags_core.check @@ -1,26 +1,30 @@ -true -TypeTag[Byte] -true -TypeTag[Short] -true -TypeTag[Char] -true -TypeTag[Int] -true -TypeTag[Long] -true -TypeTag[Float] -true -TypeTag[Double] -true -TypeTag[Boolean] -true -TypeTag[Unit] -true -TypeTag[Any] -true -TypeTag[java.lang.Object] -true -TypeTag[Null] -true -TypeTag[Nothing] +true
+TypeTag[Byte]
+true
+TypeTag[Short]
+true
+TypeTag[Char]
+true
+TypeTag[Int]
+true
+TypeTag[Long]
+true
+TypeTag[Float]
+true
+TypeTag[Double]
+true
+TypeTag[Boolean]
+true
+TypeTag[Unit]
+true
+TypeTag[Any]
+true
+TypeTag[AnyVal]
+true
+TypeTag[AnyRef]
+true
+TypeTag[java.lang.Object]
+true
+TypeTag[Null]
+true
+TypeTag[Nothing]
diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala index 0d86fac25b..5257d55118 100644 --- a/test/files/run/typetags_core.scala +++ b/test/files/run/typetags_core.scala @@ -21,6 +21,10 @@ object Test extends App { println(implicitly[TypeTag[Unit]]) println(implicitly[TypeTag[Any]] eq TypeTag.Any) println(implicitly[TypeTag[Any]]) + println(implicitly[TypeTag[AnyVal]] eq TypeTag.AnyVal) + println(implicitly[TypeTag[AnyVal]]) + println(implicitly[TypeTag[AnyRef]] eq TypeTag.AnyRef) + println(implicitly[TypeTag[AnyRef]]) println(implicitly[TypeTag[Object]] eq TypeTag.Object) println(implicitly[TypeTag[Object]]) println(implicitly[TypeTag[Null]] eq TypeTag.Null) |