summaryrefslogtreecommitdiff
path: root/test/instrumented
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-06-07 15:44:04 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-06-08 15:32:46 +0200
commitbc5f42f51982eb473075bbd2f474a5d628813031 (patch)
treea57578c5a21ced5ed38c1a098646fa95ea88f5c2 /test/instrumented
parent07f7baa21c165d6c2302a8ea26c475968e7d775e (diff)
downloadscala-bc5f42f51982eb473075bbd2f474a5d628813031.tar.gz
scala-bc5f42f51982eb473075bbd2f474a5d628813031.tar.bz2
scala-bc5f42f51982eb473075bbd2f474a5d628813031.zip
removes array tags
Before 2.10 we had a notion of ClassManifest that could be used to retain erasures of abstract types (type parameters, abstract type members) for being used at runtime. With the advent of ClassManifest (and its subtype Manifest) it became possible to write: def mkGenericArray[T: Manifest] = Array[T]() When compiling array instantiation, scalac would use a ClassManifest implicit parameter from scope (in this case, provided by a context bound) to remember Ts that have been passed to invoke mkGenericArray and use that information to instantiate arrays at runtime (via Java reflection). When redesigning manifests into what is now known as type tags, we decided to explore a notion of ArrayTags that would stand for abstract and pure array creators. Sure, ClassManifests were perfectly fine for this job, but they did too much - technically speaking, one doesn't necessarily need a java.lang.Class to create an array. Depending on a platform, e.g. within JavaScript runtime, one would want to use a different mechanism. As tempting as this idea was, it has also proven to be problematic. First, it created an extra abstraction inside the compiler. Along with class tags and type tags, we had a third flavor of tags - array tags. This has threaded the additional complexity though implicits and typers. Second, consequently, when redesigning tags multiple times over the course of Scala 2.10.0 development, we had to carry this extra abstraction with us, which exacerbated the overall feeling towards array tags. Finally, array tags didn't fit into the naming scheme we had for tags. Both class tags and type tags sound logical, because, they are descriptors for the things they are supposed to tag, according to their names. However array tags are the odd ones, because they don't actually tag any arrays. As funny as it might sound, the naming problem was the last straw that made us do away with the array tags. Hence this commit.
Diffstat (limited to 'test/instrumented')
-rw-r--r--test/instrumented/library/scala/runtime/ScalaRunTime.scala3
-rw-r--r--test/instrumented/srt.patch69
2 files changed, 56 insertions, 16 deletions
diff --git a/test/instrumented/library/scala/runtime/ScalaRunTime.scala b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
index f0d452a9be..5a3f83015f 100644
--- a/test/instrumented/library/scala/runtime/ScalaRunTime.scala
+++ b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
@@ -14,7 +14,7 @@ import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator }
import scala.collection.mutable.WrappedArray
import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: }
import scala.collection.generic.{ Sorted }
-import scala.reflect.{ ArrayTag, ClassTag, arrayTag, classTag }
+import scala.reflect.{ ClassTag, classTag }
import scala.util.control.ControlThrowable
import scala.xml.{ Node, MetaData }
@@ -63,7 +63,6 @@ object ScalaRunTime {
def arrayElementClass(schematic: Any): Class[_] = schematic match {
case cls: Class[_] => cls.getComponentType
case tag: ClassTag[_] => tag.runtimeClass
- case tag: ArrayTag[_] => tag.newArray(0).getClass.getComponentType
case _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass))
}
diff --git a/test/instrumented/srt.patch b/test/instrumented/srt.patch
index 366763e7f9..47dcfa2197 100644
--- a/test/instrumented/srt.patch
+++ b/test/instrumented/srt.patch
@@ -1,26 +1,67 @@
-9a10,11
+8a9,10
> /* INSTRUMENTED VERSION */
->
-44c46,49
-< def isTuple(x: Any) = x != null && tupleNames(x.getClass.getName)
----
+>
+73a76,77
> var arrayApplyCount = 0
-> var arrayUpdateCount = 0
->
-> def isTuple(x: Any) = tupleNames(x.getClass.getName)
-76c81,83
+>
+75,86c79,93
< def array_apply(xs: AnyRef, idx: Int): Any = xs match {
+< case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
+< case x: Array[Int] => x(idx).asInstanceOf[Any]
+< case x: Array[Double] => x(idx).asInstanceOf[Any]
+< case x: Array[Long] => x(idx).asInstanceOf[Any]
+< case x: Array[Float] => x(idx).asInstanceOf[Any]
+< case x: Array[Char] => x(idx).asInstanceOf[Any]
+< case x: Array[Byte] => x(idx).asInstanceOf[Any]
+< case x: Array[Short] => x(idx).asInstanceOf[Any]
+< case x: Array[Boolean] => x(idx).asInstanceOf[Any]
+< case x: Array[Unit] => x(idx).asInstanceOf[Any]
+< case null => throw new NullPointerException
---
> def array_apply(xs: AnyRef, idx: Int): Any = {
> arrayApplyCount += 1
> xs match {
-88a96
-> }
-91c99,101
+> case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
+> case x: Array[Int] => x(idx).asInstanceOf[Any]
+> case x: Array[Double] => x(idx).asInstanceOf[Any]
+> case x: Array[Long] => x(idx).asInstanceOf[Any]
+> case x: Array[Float] => x(idx).asInstanceOf[Any]
+> case x: Array[Char] => x(idx).asInstanceOf[Any]
+> case x: Array[Byte] => x(idx).asInstanceOf[Any]
+> case x: Array[Short] => x(idx).asInstanceOf[Any]
+> case x: Array[Boolean] => x(idx).asInstanceOf[Any]
+> case x: Array[Unit] => x(idx).asInstanceOf[Any]
+> case null => throw new NullPointerException
+> }
+88a96,97
+> var arrayUpdateCount = 0
+>
+90,101c99,113
< def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match {
+< case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
+< case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
+< case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
+< case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
+< case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
+< case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
+< case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
+< case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
+< case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
+< case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
+< case null => throw new NullPointerException
---
> def array_update(xs: AnyRef, idx: Int, value: Any): Unit = {
> arrayUpdateCount += 1
> xs match {
-102a113
-> }
+> case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
+> case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
+> case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
+> case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
+> case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
+> case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
+> case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
+> case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
+> case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
+> case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
+> case null => throw new NullPointerException
+> }