diff options
Diffstat (limited to 'test/files/run')
114 files changed, 2341 insertions, 200 deletions
diff --git a/test/files/run/arrayclone-new.scala b/test/files/run/arrayclone-new.scala new file mode 100644 index 0000000000..a4ba021409 --- /dev/null +++ b/test/files/run/arrayclone-new.scala @@ -0,0 +1,106 @@ +object Test extends App{ + BooleanArrayClone; + ByteArrayClone; + ShortArrayClone; + CharArrayClone; + IntArrayClone; + LongArrayClone; + FloatArrayClone; + DoubleArrayClone; + ObjectArrayClone; + PolymorphicArrayClone; +} + +object BooleanArrayClone{ + val it : Array[Boolean] = Array(true, false); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = false; + assert(it(0) == true) +} + +object ByteArrayClone{ + val it : Array[Byte] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object ShortArrayClone{ + val it : Array[Short] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object CharArrayClone{ + val it : Array[Char] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object IntArrayClone{ + val it : Array[Int] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object LongArrayClone{ + val it : Array[Long] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object FloatArrayClone{ + val it : Array[Float] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object DoubleArrayClone{ + val it : Array[Double] = Array(1, 0); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = 0; + assert(it(0) == 1) +} + +object ObjectArrayClone{ + val it : Array[String] = Array("1", "0"); + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = "0"; + assert(it(0) == "1") +} + +object PolymorphicArrayClone{ + def testIt[T](it : Array[T], one : T, zero : T) = { + val cloned = it.clone(); + assert(cloned.sameElements(it)); + cloned(0) = zero; + assert(it(0) == one) + } + + testIt(Array("one", "two"), "one", "two"); + + class Mangler[T: ArrayTag](ts : T*){ + // this will always be a BoxedAnyArray even after we've unboxed its contents. + val it = ts.toArray[T]; + } + + val mangled = new Mangler[Int](0, 1); + + val y : Array[Int] = mangled.it; // make sure it's unboxed + + testIt(mangled.it, 0, 1); +} diff --git a/test/files/run/arrayclone.scala b/test/files/run/arrayclone-old.scala index c9f7556b47..c9f7556b47 100644 --- a/test/files/run/arrayclone.scala +++ b/test/files/run/arrayclone-old.scala diff --git a/test/files/run/arraytags_basic.check b/test/files/run/arraytags_basic.check new file mode 100644 index 0000000000..92816b91bd --- /dev/null +++ b/test/files/run/arraytags_basic.check @@ -0,0 +1,36 @@ +class [I
+class [[I
+class [[[I
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.Map;
+class [[Lscala.collection.immutable.Map;
+class [[[Lscala.collection.immutable.Map;
+class [[I
+class [[[I
+class [[[[I
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.Map;
+class [[[Lscala.collection.immutable.Map;
+class [[[[Lscala.collection.immutable.Map;
+class [[[I
+class [[[[I
+class [[[[[I
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[[[[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[[[Lscala.collection.immutable.List;
+class [[[[[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.Map;
+class [[[[Lscala.collection.immutable.Map;
+class [[[[[Lscala.collection.immutable.Map;
diff --git a/test/files/run/arraytags_basic.scala b/test/files/run/arraytags_basic.scala new file mode 100644 index 0000000000..edc20e9bc1 --- /dev/null +++ b/test/files/run/arraytags_basic.scala @@ -0,0 +1,22 @@ +object Test extends App { + def test[T: ArrayTag] = { + println(implicitly[ArrayTag[T]].newArray(10).getClass) + println(implicitly[ArrayTag[T]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[T]]].wrap.newArray(10).getClass) + } + + test[Int] + test[List[Int]] + test[List[String]] + test[Map[Int, String]] + + test[Array[Int]] + test[Array[List[Int]]] + test[Array[List[String]]] + test[Array[Map[Int, String]]] + + test[Array[Array[Int]]] + test[Array[Array[List[Int]]]] + test[Array[Array[List[String]]]] + test[Array[Array[Map[Int, String]]]] +}
\ No newline at end of file diff --git a/test/files/run/arraytags_core.check b/test/files/run/arraytags_core.check new file mode 100644 index 0000000000..82ed84ad78 --- /dev/null +++ b/test/files/run/arraytags_core.check @@ -0,0 +1,48 @@ +class [B
+class [[B
+class [[[B
+class [S
+class [[S
+class [[[S
+class [C
+class [[C
+class [[[C
+class [I
+class [[I
+class [[[I
+class [J
+class [[J
+class [[[J
+class [F
+class [[F
+class [[[F
+class [D
+class [[D
+class [[[D
+class [Z
+class [[Z
+class [[[Z
+class [Lscala.runtime.BoxedUnit;
+class [[Lscala.runtime.BoxedUnit;
+class [[[Lscala.runtime.BoxedUnit;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Ljava.lang.Object;
+class [[Ljava.lang.Object;
+class [[[Ljava.lang.Object;
+class [Lscala.runtime.Null$;
+class [[Lscala.runtime.Null$;
+class [[[Lscala.runtime.Null$;
+class [Lscala.runtime.Nothing$;
+class [[Lscala.runtime.Nothing$;
+class [[[Lscala.runtime.Nothing$;
+class [Ljava.lang.String;
+class [[Ljava.lang.String;
+class [[[Ljava.lang.String;
diff --git a/test/files/run/arraytags_core.scala b/test/files/run/arraytags_core.scala new file mode 100644 index 0000000000..a59ae24f30 --- /dev/null +++ b/test/files/run/arraytags_core.scala @@ -0,0 +1,50 @@ +object Test extends App { + println(implicitly[ArrayTag[Byte]].newArray(10).getClass) + println(implicitly[ArrayTag[Byte]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Byte]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Short]].newArray(10).getClass) + println(implicitly[ArrayTag[Short]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Short]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Char]].newArray(10).getClass) + println(implicitly[ArrayTag[Char]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Char]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Int]].newArray(10).getClass) + println(implicitly[ArrayTag[Int]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Int]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Long]].newArray(10).getClass) + println(implicitly[ArrayTag[Long]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Long]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Float]].newArray(10).getClass) + println(implicitly[ArrayTag[Float]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Float]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Double]].newArray(10).getClass) + println(implicitly[ArrayTag[Double]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Double]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Boolean]].newArray(10).getClass) + println(implicitly[ArrayTag[Boolean]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Boolean]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Unit]].newArray(10).getClass) + println(implicitly[ArrayTag[Unit]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Unit]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Any]].newArray(10).getClass) + println(implicitly[ArrayTag[Any]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Any]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Object]].newArray(10).getClass) + println(implicitly[ArrayTag[Object]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Object]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[AnyVal]].newArray(10).getClass) + println(implicitly[ArrayTag[AnyVal]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[AnyVal]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[AnyRef]].newArray(10).getClass) + println(implicitly[ArrayTag[AnyRef]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[AnyRef]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Null]].newArray(10).getClass) + println(implicitly[ArrayTag[Null]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Null]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Nothing]].newArray(10).getClass) + println(implicitly[ArrayTag[Nothing]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[Nothing]]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[String]].newArray(10).getClass) + println(implicitly[ArrayTag[String]].wrap.newArray(10).getClass) + println(implicitly[ArrayTag[Array[String]]].wrap.newArray(10).getClass) +}
\ No newline at end of file diff --git a/test/files/run/arraytags_usage.check b/test/files/run/arraytags_usage.check new file mode 100644 index 0000000000..b1d02b7bfe --- /dev/null +++ b/test/files/run/arraytags_usage.check @@ -0,0 +1,3 @@ +class [I
+class [I
+class [I
diff --git a/test/files/run/arraytags_usage.scala b/test/files/run/arraytags_usage.scala new file mode 100644 index 0000000000..60b0a8f218 --- /dev/null +++ b/test/files/run/arraytags_usage.scala @@ -0,0 +1,15 @@ +object Test extends App { + def foo[T] = { + class MyArrayTag extends ArrayTag[T] { + def wrap: ArrayTag[Array[T]] = ??? + def newArray(len: Int): Array[T] = new Array[Int](len).asInstanceOf[Array[T]] + } + + implicit val tag = new MyArrayTag() + println(Array[T]().getClass) + } + + foo[Int] + foo[String] + foo[Array[String]] +}
\ No newline at end of file diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index ce5a893b08..ebccfcd54c 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -1,30 +1,32 @@ -true
-ClassTag(byte)
-true
-ClassTag(short)
-true
-ClassTag(char)
-true
-ClassTag(int)
-true
-ClassTag(long)
-true
-ClassTag(float)
-true
-ClassTag(double)
-true
-ClassTag(boolean)
-true
-ClassTag(void)
-true
-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 java.lang.Object)
-true
-ClassTag(class java.lang.Object)
+true +ClassTag[byte] +true +ClassTag[short] +true +ClassTag[char] +true +ClassTag[int] +true +ClassTag[long] +true +ClassTag[float] +true +ClassTag[double] +true +ClassTag[boolean] +true +ClassTag[void] +true +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$] +true +ClassTag[class java.lang.String] diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala index 45c54b1fe0..9f2031377d 100644 --- a/test/files/run/classtags_core.scala +++ b/test/files/run/classtags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[ClassTag[Null]]) println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing) println(implicitly[ClassTag[Nothing]]) + println(implicitly[ClassTag[String]] eq ClassTag.String) + println(implicitly[ClassTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/classtags_multi.check b/test/files/run/classtags_multi.check new file mode 100644 index 0000000000..3a7f16c3a0 --- /dev/null +++ b/test/files/run/classtags_multi.check @@ -0,0 +1,5 @@ +ClassTag[int]
+ClassTag[class [I]
+ClassTag[class [[I]
+ClassTag[class [[[I]
+ClassTag[class [[[[I]
diff --git a/test/files/run/classtags_multi.scala b/test/files/run/classtags_multi.scala new file mode 100644 index 0000000000..5aafb55223 --- /dev/null +++ b/test/files/run/classtags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(classTag[Int]) + println(classTag[Array[Int]]) + println(classTag[Array[Array[Int]]]) + println(classTag[Array[Array[Array[Int]]]]) + println(classTag[Array[Array[Array[Array[Int]]]]]) +}
\ No newline at end of file diff --git a/test/files/run/classtags_use_concretetypetags.scala b/test/files/run/classtags_use_concretetypetags.scala new file mode 100644 index 0000000000..57e7085cec --- /dev/null +++ b/test/files/run/classtags_use_concretetypetags.scala @@ -0,0 +1,3 @@ +object Test extends App { + def foo[T: ConcreteTypeTag] = Array[T]() +}
\ No newline at end of file diff --git a/test/files/run/groundtypetags_core.check b/test/files/run/concretetypetags_core.check index 62fcb481ae..f124aa6a35 100644 --- a/test/files/run/groundtypetags_core.check +++ b/test/files/run/concretetypetags_core.check @@ -1,30 +1,32 @@ -true
-ConcreteTypeTag[Byte]
-true
-ConcreteTypeTag[Short]
-true
-ConcreteTypeTag[Char]
-true
-ConcreteTypeTag[Int]
-true
-ConcreteTypeTag[Long]
-true
-ConcreteTypeTag[Float]
-true
-ConcreteTypeTag[Double]
-true
-ConcreteTypeTag[Boolean]
-true
-ConcreteTypeTag[Unit]
-true
-ConcreteTypeTag[Any]
-true
-ConcreteTypeTag[Object]
-true
-ConcreteTypeTag[AnyVal]
-true
-ConcreteTypeTag[AnyRef]
-true
-ConcreteTypeTag[Null]
-true
-ConcreteTypeTag[Nothing]
+true +ConcreteTypeTag[Byte] +true +ConcreteTypeTag[Short] +true +ConcreteTypeTag[Char] +true +ConcreteTypeTag[Int] +true +ConcreteTypeTag[Long] +true +ConcreteTypeTag[Float] +true +ConcreteTypeTag[Double] +true +ConcreteTypeTag[Boolean] +true +ConcreteTypeTag[Unit] +true +ConcreteTypeTag[Any] +true +ConcreteTypeTag[Object] +true +ConcreteTypeTag[AnyVal] +true +ConcreteTypeTag[AnyRef] +true +ConcreteTypeTag[Null] +true +ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[String] diff --git a/test/files/run/groundtypetags_core.scala b/test/files/run/concretetypetags_core.scala index 8b81a0c795..b6cfea3895 100644 --- a/test/files/run/groundtypetags_core.scala +++ b/test/files/run/concretetypetags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[ConcreteTypeTag[Null]]) println(implicitly[ConcreteTypeTag[Nothing]] eq ConcreteTypeTag.Nothing) println(implicitly[ConcreteTypeTag[Nothing]]) + println(implicitly[ConcreteTypeTag[String]] eq ConcreteTypeTag.String) + println(implicitly[ConcreteTypeTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/concretetypetags_multi.check b/test/files/run/concretetypetags_multi.check new file mode 100644 index 0000000000..613106985c --- /dev/null +++ b/test/files/run/concretetypetags_multi.check @@ -0,0 +1,5 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[Array[Int]]
+ConcreteTypeTag[Array[Array[Int]]]
+ConcreteTypeTag[Array[Array[Array[Int]]]]
+ConcreteTypeTag[Array[Array[Array[Array[Int]]]]]
diff --git a/test/files/run/concretetypetags_multi.scala b/test/files/run/concretetypetags_multi.scala new file mode 100644 index 0000000000..7e19d7db34 --- /dev/null +++ b/test/files/run/concretetypetags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(concreteTypeTag[Int]) + println(concreteTypeTag[Array[Int]]) + println(concreteTypeTag[Array[Array[Int]]]) + println(concreteTypeTag[Array[Array[Array[Int]]]]) + println(concreteTypeTag[Array[Array[Array[Array[Int]]]]]) +}
\ No newline at end of file diff --git a/test/files/run/ctries/DumbHash.scala b/test/files/run/ctries-new/DumbHash.scala index 8ef325b67c..8ef325b67c 100644 --- a/test/files/run/ctries/DumbHash.scala +++ b/test/files/run/ctries-new/DumbHash.scala diff --git a/test/files/run/ctries/Wrap.scala b/test/files/run/ctries-new/Wrap.scala index 7b645c1612..7b645c1612 100644 --- a/test/files/run/ctries/Wrap.scala +++ b/test/files/run/ctries-new/Wrap.scala diff --git a/test/files/run/ctries/concmap.scala b/test/files/run/ctries-new/concmap.scala index 3ec0256afb..3ec0256afb 100644 --- a/test/files/run/ctries/concmap.scala +++ b/test/files/run/ctries-new/concmap.scala diff --git a/test/files/run/ctries/iterator.scala b/test/files/run/ctries-new/iterator.scala index b953a40e00..b953a40e00 100644 --- a/test/files/run/ctries/iterator.scala +++ b/test/files/run/ctries-new/iterator.scala diff --git a/test/files/run/ctries/lnode.scala b/test/files/run/ctries-new/lnode.scala index 92a31088e5..92a31088e5 100644 --- a/test/files/run/ctries/lnode.scala +++ b/test/files/run/ctries-new/lnode.scala diff --git a/test/files/run/ctries-new/main.scala b/test/files/run/ctries-new/main.scala new file mode 100644 index 0000000000..1d40dab6c5 --- /dev/null +++ b/test/files/run/ctries-new/main.scala @@ -0,0 +1,45 @@ + + + + + + + +object Test { + + def main(args: Array[String]) { + ConcurrentMapSpec.test() + IteratorSpec.test() + LNodeSpec.test() + SnapshotSpec.test() + } + +} + + +trait Spec { + + implicit def str2ops(s: String) = new { + def in[U](body: =>U) { + // just execute body + body + } + } + + implicit def any2ops(a: Any) = new { + def shouldEqual(other: Any) = assert(a == other) + } + + def evaluating[U](body: =>U) = new { + def shouldProduce[T <: Throwable: ClassTag]() = { + var produced = false + try body + catch { + case e => if (e.getClass == implicitly[ClassTag[T]].erasure) produced = true + } finally { + assert(produced, "Did not produce exception of type: " + implicitly[ClassTag[T]]) + } + } + } + +} diff --git a/test/files/run/ctries/snapshot.scala b/test/files/run/ctries-new/snapshot.scala index 5fe77d445b..5fe77d445b 100644 --- a/test/files/run/ctries/snapshot.scala +++ b/test/files/run/ctries-new/snapshot.scala diff --git a/test/files/run/ctries-old/DumbHash.scala b/test/files/run/ctries-old/DumbHash.scala new file mode 100644 index 0000000000..8ef325b67c --- /dev/null +++ b/test/files/run/ctries-old/DumbHash.scala @@ -0,0 +1,14 @@ + + + + + + +class DumbHash(val i: Int) { + override def equals(other: Any) = other match { + case that: DumbHash => that.i == this.i + case _ => false + } + override def hashCode = i % 5 + override def toString = "DH(%s)".format(i) +} diff --git a/test/files/run/ctries-old/Wrap.scala b/test/files/run/ctries-old/Wrap.scala new file mode 100644 index 0000000000..7b645c1612 --- /dev/null +++ b/test/files/run/ctries-old/Wrap.scala @@ -0,0 +1,9 @@ + + + + + + +case class Wrap(i: Int) { + override def hashCode = i * 0x9e3775cd +} diff --git a/test/files/run/ctries-old/concmap.scala b/test/files/run/ctries-old/concmap.scala new file mode 100644 index 0000000000..3ec0256afb --- /dev/null +++ b/test/files/run/ctries-old/concmap.scala @@ -0,0 +1,188 @@ + + + +import collection.concurrent.TrieMap + + +object ConcurrentMapSpec extends Spec { + + val initsz = 500 + val secondsz = 750 + + def test() { + "support put" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) assert(ct.put(new Wrap(i), i) == None) + for (i <- 0 until initsz) assert(ct.put(new Wrap(i), -i) == Some(i)) + } + + "support put if absent" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.putIfAbsent(new Wrap(i), -i) == Some(i)) + for (i <- 0 until initsz) assert(ct.putIfAbsent(new Wrap(i), -i) == Some(i)) + for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), -i) == None) + for (i <- initsz until secondsz) assert(ct.putIfAbsent(new Wrap(i), i) == Some(-i)) + } + + "support remove if mapped to a specific value" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), -i - 1) == false) + for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == true) + for (i <- 0 until initsz) assert(ct.remove(new Wrap(i), i) == false) + } + + "support replace if mapped to a specific value" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), -i - 1, -i - 2) == false) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == true) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i, -i - 2) == false) + for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i, 0) == false) + } + + "support replace if present" in { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until initsz) ct.update(new Wrap(i), i) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), -i) == Some(i)) + for (i <- 0 until initsz) assert(ct.replace(new Wrap(i), i) == Some(-i)) + for (i <- initsz until secondsz) assert(ct.replace(new Wrap(i), i) == None) + } + + def assertEqual(a: Any, b: Any) = { + if (a != b) println(a, b) + assert(a == b) + } + + "support replace if mapped to a specific value, using several threads" in { + val ct = new TrieMap[Wrap, Int] + val sz = 55000 + for (i <- 0 until sz) ct.update(new Wrap(i), i) + + class Updater(index: Int, offs: Int) extends Thread { + override def run() { + var repeats = 0 + for (i <- 0 until sz) { + val j = (offs + i) % sz + var k = Int.MaxValue + do { + if (k != Int.MaxValue) repeats += 1 + k = ct.lookup(new Wrap(j)) + } while (!ct.replace(new Wrap(j), k, -k)) + } + //println("Thread %d repeats: %d".format(index, repeats)) + } + } + + val threads = for (i <- 0 until 16) yield new Updater(i, sz / 32 * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), i) + + val threads2 = for (i <- 0 until 15) yield new Updater(i, sz / 32 * i) + threads2.foreach(_.start()) + threads2.foreach(_.join()) + + for (i <- 0 until sz) assertEqual(ct(new Wrap(i)), -i) + } + + "support put if absent, several threads" in { + val ct = new TrieMap[Wrap, Int] + val sz = 110000 + + class Updater(offs: Int) extends Thread { + override def run() { + for (i <- 0 until sz) { + val j = (offs + i) % sz + ct.putIfAbsent(new Wrap(j), j) + assert(ct.lookup(new Wrap(j)) == j) + } + } + } + + val threads = for (i <- 0 until 16) yield new Updater(sz / 32 * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + + for (i <- 0 until sz) assert(ct(new Wrap(i)) == i) + } + + "support remove if mapped to a specific value, several threads" in { + val ct = new TrieMap[Wrap, Int] + val sz = 55000 + for (i <- 0 until sz) ct.update(new Wrap(i), i) + + class Remover(offs: Int) extends Thread { + override def run() { + for (i <- 0 until sz) { + val j = (offs + i) % sz + ct.remove(new Wrap(j), j) + assert(ct.get(new Wrap(j)) == None) + } + } + } + + val threads = for (i <- 0 until 16) yield new Remover(sz / 32 * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + + for (i <- 0 until sz) assert(ct.get(new Wrap(i)) == None) + } + + "have all or none of the elements depending on the oddity" in { + val ct = new TrieMap[Wrap, Int] + val sz = 65000 + for (i <- 0 until sz) ct(new Wrap(i)) = i + + class Modifier(index: Int, offs: Int) extends Thread { + override def run() { + for (j <- 0 until sz) { + val i = (offs + j) % sz + var success = false + do { + if (ct.contains(new Wrap(i))) { + success = ct.remove(new Wrap(i)) != None + } else { + success = ct.putIfAbsent(new Wrap(i), i) == None + } + } while (!success) + } + } + } + + def modify(n: Int) = { + val threads = for (i <- 0 until n) yield new Modifier(i, sz / n * i) + threads.foreach(_.start()) + threads.foreach(_.join()) + } + + modify(16) + for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), Some(i)) + modify(15) + for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), None) + } + + "compute size correctly" in { + val ct = new TrieMap[Wrap, Int] + val sz = 36450 + for (i <- 0 until sz) ct(new Wrap(i)) = i + + assertEqual(ct.size, sz) + assertEqual(ct.size, sz) + } + + "compute size correctly in parallel" in { + val ct = new TrieMap[Wrap, Int] + val sz = 36450 + for (i <- 0 until sz) ct(new Wrap(i)) = i + val pct = ct.par + + assertEqual(pct.size, sz) + assertEqual(pct.size, sz) + } + + } + +} diff --git a/test/files/run/ctries-old/iterator.scala b/test/files/run/ctries-old/iterator.scala new file mode 100644 index 0000000000..b953a40e00 --- /dev/null +++ b/test/files/run/ctries-old/iterator.scala @@ -0,0 +1,289 @@ + + + + +import collection._ +import collection.concurrent.TrieMap + + + +object IteratorSpec extends Spec { + + def test() { + "work for an empty trie" in { + val ct = new TrieMap + val it = ct.iterator + + it.hasNext shouldEqual (false) + evaluating { it.next() }.shouldProduce [NoSuchElementException] + } + + def nonEmptyIteratorCheck(sz: Int) { + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + + val it = ct.iterator + val tracker = mutable.Map[Wrap, Int]() + for (i <- 0 until sz) { + assert(it.hasNext == true) + tracker += it.next + } + + it.hasNext shouldEqual (false) + evaluating { it.next() }.shouldProduce [NoSuchElementException] + tracker.size shouldEqual (sz) + tracker shouldEqual (ct) + } + + "work for a 1 element trie" in { + nonEmptyIteratorCheck(1) + } + + "work for a 2 element trie" in { + nonEmptyIteratorCheck(2) + } + + "work for a 3 element trie" in { + nonEmptyIteratorCheck(3) + } + + "work for a 5 element trie" in { + nonEmptyIteratorCheck(5) + } + + "work for a 10 element trie" in { + nonEmptyIteratorCheck(10) + } + + "work for a 20 element trie" in { + nonEmptyIteratorCheck(20) + } + + "work for a 50 element trie" in { + nonEmptyIteratorCheck(50) + } + + "work for a 100 element trie" in { + nonEmptyIteratorCheck(100) + } + + "work for a 1k element trie" in { + nonEmptyIteratorCheck(1000) + } + + "work for a 5k element trie" in { + nonEmptyIteratorCheck(5000) + } + + "work for a 75k element trie" in { + nonEmptyIteratorCheck(75000) + } + + "work for a 250k element trie" in { + nonEmptyIteratorCheck(500000) + } + + def nonEmptyCollideCheck(sz: Int) { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until sz) ct.put(new DumbHash(i), i) + + val it = ct.iterator + val tracker = mutable.Map[DumbHash, Int]() + for (i <- 0 until sz) { + assert(it.hasNext == true) + tracker += it.next + } + + it.hasNext shouldEqual (false) + evaluating { it.next() }.shouldProduce [NoSuchElementException] + tracker.size shouldEqual (sz) + tracker shouldEqual (ct) + } + + "work for colliding hashcodes, 2 element trie" in { + nonEmptyCollideCheck(2) + } + + "work for colliding hashcodes, 3 element trie" in { + nonEmptyCollideCheck(3) + } + + "work for colliding hashcodes, 5 element trie" in { + nonEmptyCollideCheck(5) + } + + "work for colliding hashcodes, 10 element trie" in { + nonEmptyCollideCheck(10) + } + + "work for colliding hashcodes, 100 element trie" in { + nonEmptyCollideCheck(100) + } + + "work for colliding hashcodes, 500 element trie" in { + nonEmptyCollideCheck(500) + } + + "work for colliding hashcodes, 5k element trie" in { + nonEmptyCollideCheck(5000) + } + + def assertEqual(a: Map[Wrap, Int], b: Map[Wrap, Int]) { + if (a != b) { + println(a.size + " vs " + b.size) + // println(a) + // println(b) + // println(a.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) + // println(b.toSeq.sortBy((x: (Wrap, Int)) => x._1.i)) + } + assert(a == b) + } + + "be consistent when taken with concurrent modifications" in { + val sz = 25000 + val W = 15 + val S = 5 + val checks = 5 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + + class Modifier extends Thread { + override def run() { + for (i <- 0 until sz) ct.putIfAbsent(new Wrap(i), i) match { + case Some(_) => ct.remove(new Wrap(i)) + case None => + } + } + } + + def consistentIteration(ct: TrieMap[Wrap, Int], checks: Int) { + class Iter extends Thread { + override def run() { + val snap = ct.readOnlySnapshot() + val initial = mutable.Map[Wrap, Int]() + for (kv <- snap) initial += kv + + for (i <- 0 until checks) { + assertEqual(snap.iterator.toMap, initial) + } + } + } + + val iter = new Iter + iter.start() + iter.join() + } + + val threads = for (_ <- 0 until W) yield new Modifier + threads.foreach(_.start()) + for (_ <- 0 until S) consistentIteration(ct, checks) + threads.foreach(_.join()) + } + + "be consistent with a concurrent removal with a well defined order" in { + val sz = 150000 + val sgroupsize = 10 + val sgroupnum = 5 + val removerslowdown = 50 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + + class Remover extends Thread { + override def run() { + for (i <- 0 until sz) { + assert(ct.remove(new Wrap(i)) == Some(i)) + for (i <- 0 until removerslowdown) ct.get(new Wrap(i)) // slow down, mate + } + //println("done removing") + } + } + + def consistentIteration(it: Iterator[(Wrap, Int)]) = { + class Iter extends Thread { + override def run() { + val elems = it.toBuffer + if (elems.nonEmpty) { + val minelem = elems.minBy((x: (Wrap, Int)) => x._1.i)._1.i + assert(elems.forall(_._1.i >= minelem)) + } + } + } + new Iter + } + + val remover = new Remover + remover.start() + for (_ <- 0 until sgroupnum) { + val iters = for (_ <- 0 until sgroupsize) yield consistentIteration(ct.iterator) + iters.foreach(_.start()) + iters.foreach(_.join()) + } + //println("done with iterators") + remover.join() + } + + "be consistent with a concurrent insertion with a well defined order" in { + val sz = 150000 + val sgroupsize = 10 + val sgroupnum = 10 + val inserterslowdown = 50 + val ct = new TrieMap[Wrap, Int] + + class Inserter extends Thread { + override def run() { + for (i <- 0 until sz) { + assert(ct.put(new Wrap(i), i) == None) + for (i <- 0 until inserterslowdown) ct.get(new Wrap(i)) // slow down, mate + } + //println("done inserting") + } + } + + def consistentIteration(it: Iterator[(Wrap, Int)]) = { + class Iter extends Thread { + override def run() { + val elems = it.toSeq + if (elems.nonEmpty) { + val maxelem = elems.maxBy((x: (Wrap, Int)) => x._1.i)._1.i + assert(elems.forall(_._1.i <= maxelem)) + } + } + } + new Iter + } + + val inserter = new Inserter + inserter.start() + for (_ <- 0 until sgroupnum) { + val iters = for (_ <- 0 until sgroupsize) yield consistentIteration(ct.iterator) + iters.foreach(_.start()) + iters.foreach(_.join()) + } + //println("done with iterators") + inserter.join() + } + + "work on a yet unevaluated snapshot" in { + val sz = 50000 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.update(new Wrap(i), i) + + val snap = ct.snapshot() + val it = snap.iterator + + while (it.hasNext) it.next() + } + + "be duplicated" in { + val sz = 50 + val ct = collection.parallel.mutable.ParTrieMap((0 until sz) zip (0 until sz): _*) + val it = ct.splitter + for (_ <- 0 until (sz / 2)) it.next() + val dupit = it.dup + + it.toList shouldEqual dupit.toList + } + + } + +} diff --git a/test/files/run/ctries-old/lnode.scala b/test/files/run/ctries-old/lnode.scala new file mode 100644 index 0000000000..92a31088e5 --- /dev/null +++ b/test/files/run/ctries-old/lnode.scala @@ -0,0 +1,61 @@ + + + +import collection.concurrent.TrieMap + + +object LNodeSpec extends Spec { + + val initsz = 1500 + val secondsz = 1750 + + def test() { + "accept elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.update(new DumbHash(i), i) + } + + "lookup elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.update(new DumbHash(i), i) + for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == Some(i)) + for (i <- initsz until secondsz) assert(ct.get(new DumbHash(i)) == None) + } + + "remove elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.update(new DumbHash(i), i) + for (i <- 0 until initsz) { + val remelem = ct.remove(new DumbHash(i)) + assert(remelem == Some(i), "removing " + i + " yields " + remelem) + } + for (i <- 0 until initsz) assert(ct.get(new DumbHash(i)) == None) + } + + "put elements with the same hash codes if absent" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) ct.put(new DumbHash(i), i) + for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == i) + for (i <- 0 until initsz) assert(ct.putIfAbsent(new DumbHash(i), i) == Some(i)) + for (i <- initsz until secondsz) assert(ct.putIfAbsent(new DumbHash(i), i) == None) + for (i <- initsz until secondsz) assert(ct.lookup(new DumbHash(i)) == i) + } + + "replace elements with the same hash codes" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) + for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == i) + for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i) == Some(i)) + for (i <- 0 until initsz) assert(ct.lookup(new DumbHash(i)) == -i) + for (i <- 0 until initsz) assert(ct.replace(new DumbHash(i), -i, i) == true) + } + + "remove elements with the same hash codes if mapped to a specific value" in { + val ct = new TrieMap[DumbHash, Int] + for (i <- 0 until initsz) assert(ct.put(new DumbHash(i), i) == None) + for (i <- 0 until initsz) assert(ct.remove(new DumbHash(i), i) == true) + } + + } + +} diff --git a/test/files/run/ctries/main.scala b/test/files/run/ctries-old/main.scala index 8db7fcef54..8db7fcef54 100644 --- a/test/files/run/ctries/main.scala +++ b/test/files/run/ctries-old/main.scala diff --git a/test/files/run/ctries-old/snapshot.scala b/test/files/run/ctries-old/snapshot.scala new file mode 100644 index 0000000000..5fe77d445b --- /dev/null +++ b/test/files/run/ctries-old/snapshot.scala @@ -0,0 +1,267 @@ + + + + +import collection._ +import collection.concurrent.TrieMap + + + +object SnapshotSpec extends Spec { + + def test() { + "support snapshots" in { + val ctn = new TrieMap + ctn.snapshot() + ctn.readOnlySnapshot() + + val ct = new TrieMap[Int, Int] + for (i <- 0 until 100) ct.put(i, i) + ct.snapshot() + ct.readOnlySnapshot() + } + + "empty 2 quiescent snapshots in isolation" in { + val sz = 4000 + + class Worker(trie: TrieMap[Wrap, Int]) extends Thread { + override def run() { + for (i <- 0 until sz) { + assert(trie.remove(new Wrap(i)) == Some(i)) + for (j <- 0 until sz) + if (j <= i) assert(trie.get(new Wrap(j)) == None) + else assert(trie.get(new Wrap(j)) == Some(j)) + } + } + } + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct.put(new Wrap(i), i) + val snapt = ct.snapshot() + + val original = new Worker(ct) + val snapshot = new Worker(snapt) + original.start() + snapshot.start() + original.join() + snapshot.join() + + for (i <- 0 until sz) { + assert(ct.get(new Wrap(i)) == None) + assert(snapt.get(new Wrap(i)) == None) + } + } + + def consistentReadOnly(name: String, readonly: Map[Wrap, Int], sz: Int, N: Int) { + @volatile var e: Exception = null + + // reads possible entries once and stores them + // then reads all these N more times to check if the + // state stayed the same + class Reader(trie: Map[Wrap, Int]) extends Thread { + setName("Reader " + name) + + override def run() = + try check() + catch { + case ex: Exception => e = ex + } + + def check() { + val initial = mutable.Map[Wrap, Int]() + for (i <- 0 until sz) trie.get(new Wrap(i)) match { + case Some(i) => initial.put(new Wrap(i), i) + case None => // do nothing + } + + for (k <- 0 until N) { + for (i <- 0 until sz) { + val tres = trie.get(new Wrap(i)) + val ires = initial.get(new Wrap(i)) + if (tres != ires) println(i, "initially: " + ires, "traversal %d: %s".format(k, tres)) + assert(tres == ires) + } + } + } + } + + val reader = new Reader(readonly) + reader.start() + reader.join() + + if (e ne null) { + e.printStackTrace() + throw e + } + } + + // traverses the trie `rep` times and modifies each entry + class Modifier(trie: TrieMap[Wrap, Int], index: Int, rep: Int, sz: Int) extends Thread { + setName("Modifier %d".format(index)) + + override def run() { + for (k <- 0 until rep) { + for (i <- 0 until sz) trie.putIfAbsent(new Wrap(i), i) match { + case Some(_) => trie.remove(new Wrap(i)) + case None => // do nothing + } + } + } + } + + // removes all the elements from the trie + class Remover(trie: TrieMap[Wrap, Int], index: Int, totremovers: Int, sz: Int) extends Thread { + setName("Remover %d".format(index)) + + override def run() { + for (i <- 0 until sz) trie.remove(new Wrap((i + sz / totremovers * index) % sz)) + } + } + + "have a consistent quiescent read-only snapshot" in { + val sz = 10000 + val N = 100 + val W = 10 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val readonly = ct.readOnlySnapshot() + val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) + + threads.foreach(_.start()) + consistentReadOnly("qm", readonly, sz, N) + threads.foreach(_.join()) + } + + // now, we check non-quiescent snapshots, as these permit situations + // where a thread is caught in the middle of the update when a snapshot is taken + + "have a consistent non-quiescent read-only snapshot, concurrent with removes only" in { + val sz = 1250 + val W = 100 + val S = 5000 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val threads = for (i <- 0 until W) yield new Remover(ct, i, W, sz) + + threads.foreach(_.start()) + for (i <- 0 until S) consistentReadOnly("non-qr", ct.readOnlySnapshot(), sz, 5) + threads.foreach(_.join()) + } + + "have a consistent non-quiescent read-only snapshot, concurrent with modifications" in { + val sz = 1000 + val N = 7000 + val W = 10 + val S = 7000 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) + + threads.foreach(_.start()) + for (i <- 0 until S) consistentReadOnly("non-qm", ct.readOnlySnapshot(), sz, 5) + threads.foreach(_.join()) + } + + def consistentNonReadOnly(name: String, trie: TrieMap[Wrap, Int], sz: Int, N: Int) { + @volatile var e: Exception = null + + // reads possible entries once and stores them + // then reads all these N more times to check if the + // state stayed the same + class Worker extends Thread { + setName("Worker " + name) + + override def run() = + try check() + catch { + case ex: Exception => e = ex + } + + def check() { + val initial = mutable.Map[Wrap, Int]() + for (i <- 0 until sz) trie.get(new Wrap(i)) match { + case Some(i) => initial.put(new Wrap(i), i) + case None => // do nothing + } + + for (k <- 0 until N) { + // modify + for ((key, value) <- initial) { + val oldv = if (k % 2 == 0) value else -value + val newv = -oldv + trie.replace(key, oldv, newv) + } + + // check + for (i <- 0 until sz) if (initial.contains(new Wrap(i))) { + val expected = if (k % 2 == 0) -i else i + //println(trie.get(new Wrap(i))) + assert(trie.get(new Wrap(i)) == Some(expected)) + } else { + assert(trie.get(new Wrap(i)) == None) + } + } + } + } + + val worker = new Worker + worker.start() + worker.join() + + if (e ne null) { + e.printStackTrace() + throw e + } + } + + "have a consistent non-quiescent snapshot, concurrent with modifications" in { + val sz = 9000 + val N = 1000 + val W = 10 + val S = 400 + + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + val threads = for (i <- 0 until W) yield new Modifier(ct, i, N, sz) + + threads.foreach(_.start()) + for (i <- 0 until S) { + consistentReadOnly("non-qm", ct.snapshot(), sz, 5) + consistentNonReadOnly("non-qsnap", ct.snapshot(), sz, 5) + } + threads.foreach(_.join()) + } + + "work when many concurrent snapshots are taken, concurrent with modifications" in { + val sz = 12000 + val W = 10 + val S = 10 + val modifytimes = 1200 + val snaptimes = 600 + val ct = new TrieMap[Wrap, Int] + for (i <- 0 until sz) ct(new Wrap(i)) = i + + class Snapshooter extends Thread { + setName("Snapshooter") + override def run() { + for (k <- 0 until snaptimes) { + val snap = ct.snapshot() + for (i <- 0 until sz) snap.remove(new Wrap(i)) + for (i <- 0 until sz) assert(!snap.contains(new Wrap(i))) + } + } + } + + val mods = for (i <- 0 until W) yield new Modifier(ct, i, modifytimes, sz) + val shooters = for (i <- 0 until S) yield new Snapshooter + val threads = mods ++ shooters + threads.foreach(_.start()) + threads.foreach(_.join()) + } + + } + +} diff --git a/test/files/run/erasuretags_abstract.check b/test/files/run/erasuretags_abstract.check new file mode 100644 index 0000000000..17e7204664 --- /dev/null +++ b/test/files/run/erasuretags_abstract.check @@ -0,0 +1,4 @@ +class java.lang.Object
+class java.lang.Object
+class java.lang.Object
+int
diff --git a/test/files/run/erasuretags_abstract.scala b/test/files/run/erasuretags_abstract.scala new file mode 100644 index 0000000000..8e4ad0d090 --- /dev/null +++ b/test/files/run/erasuretags_abstract.scala @@ -0,0 +1,9 @@ +object Test extends App { + def foo1[T] = erasureTag[T] + println(foo1[Int].erasure) + println(foo1[String].erasure) + println(foo1[Array[Int]].erasure) + + def foo2[T <: Int] = erasureTag[T] + println(foo2[Int].erasure) +}
\ No newline at end of file diff --git a/test/files/run/erasuretags_basic.check b/test/files/run/erasuretags_basic.check new file mode 100644 index 0000000000..c02a4d32af --- /dev/null +++ b/test/files/run/erasuretags_basic.check @@ -0,0 +1,24 @@ +int
+class [I
+class scala.collection.immutable.List
+class [Lscala.collection.immutable.List;
+class scala.collection.immutable.List
+class [Lscala.collection.immutable.List;
+interface scala.collection.immutable.Map
+class [Lscala.collection.immutable.Map;
+class [I
+class [[I
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [Lscala.collection.immutable.Map;
+class [[Lscala.collection.immutable.Map;
+class [[I
+class [[[I
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.List;
+class [[[Lscala.collection.immutable.List;
+class [[Lscala.collection.immutable.Map;
+class [[[Lscala.collection.immutable.Map;
diff --git a/test/files/run/erasuretags_basic.scala b/test/files/run/erasuretags_basic.scala new file mode 100644 index 0000000000..d894fdf2e9 --- /dev/null +++ b/test/files/run/erasuretags_basic.scala @@ -0,0 +1,21 @@ +object Test extends App { + def test[T: ErasureTag] = { + println(implicitly[ErasureTag[T]].erasure) + println(implicitly[ErasureTag[Array[T]]].erasure) + } + + test[Int] + test[List[Int]] + test[List[String]] + test[Map[Int, String]] + + test[Array[Int]] + test[Array[List[Int]]] + test[Array[List[String]]] + test[Array[Map[Int, String]]] + + test[Array[Array[Int]]] + test[Array[Array[List[Int]]]] + test[Array[Array[List[String]]]] + test[Array[Array[Map[Int, String]]]] +}
\ No newline at end of file diff --git a/test/files/run/erasuretags_core.check b/test/files/run/erasuretags_core.check new file mode 100644 index 0000000000..2c544678d1 --- /dev/null +++ b/test/files/run/erasuretags_core.check @@ -0,0 +1,32 @@ +byte
+class [B
+short
+class [S
+char
+class [C
+int
+class [I
+long
+class [J
+float
+class [F
+double
+class [D
+boolean
+class [Z
+void
+class [Lscala.runtime.BoxedUnit;
+class java.lang.Object
+class [Ljava.lang.Object;
+class java.lang.Object
+class [Ljava.lang.Object;
+class java.lang.Object
+class [Ljava.lang.Object;
+class java.lang.Object
+class [Ljava.lang.Object;
+class scala.runtime.Null$
+class [Lscala.runtime.Null$;
+class scala.runtime.Nothing$
+class [Lscala.runtime.Nothing$;
+class java.lang.String
+class [Ljava.lang.String;
diff --git a/test/files/run/erasuretags_core.scala b/test/files/run/erasuretags_core.scala new file mode 100644 index 0000000000..5ed06dcd31 --- /dev/null +++ b/test/files/run/erasuretags_core.scala @@ -0,0 +1,34 @@ +object Test extends App { + println(implicitly[ErasureTag[Byte]].erasure) + println(implicitly[ErasureTag[Array[Byte]]].erasure) + println(implicitly[ErasureTag[Short]].erasure) + println(implicitly[ErasureTag[Array[Short]]].erasure) + println(implicitly[ErasureTag[Char]].erasure) + println(implicitly[ErasureTag[Array[Char]]].erasure) + println(implicitly[ErasureTag[Int]].erasure) + println(implicitly[ErasureTag[Array[Int]]].erasure) + println(implicitly[ErasureTag[Long]].erasure) + println(implicitly[ErasureTag[Array[Long]]].erasure) + println(implicitly[ErasureTag[Float]].erasure) + println(implicitly[ErasureTag[Array[Float]]].erasure) + println(implicitly[ErasureTag[Double]].erasure) + println(implicitly[ErasureTag[Array[Double]]].erasure) + println(implicitly[ErasureTag[Boolean]].erasure) + println(implicitly[ErasureTag[Array[Boolean]]].erasure) + println(implicitly[ErasureTag[Unit]].erasure) + println(implicitly[ErasureTag[Array[Unit]]].erasure) + println(implicitly[ErasureTag[Any]].erasure) + println(implicitly[ErasureTag[Array[Any]]].erasure) + println(implicitly[ErasureTag[Object]].erasure) + println(implicitly[ErasureTag[Array[Object]]].erasure) + println(implicitly[ErasureTag[AnyVal]].erasure) + println(implicitly[ErasureTag[Array[AnyVal]]].erasure) + println(implicitly[ErasureTag[AnyRef]].erasure) + println(implicitly[ErasureTag[Array[AnyRef]]].erasure) + println(implicitly[ErasureTag[Null]].erasure) + println(implicitly[ErasureTag[Array[Null]]].erasure) + println(implicitly[ErasureTag[Nothing]].erasure) + println(implicitly[ErasureTag[Array[Nothing]]].erasure) + println(implicitly[ErasureTag[String]].erasure) + println(implicitly[ErasureTag[Array[String]]].erasure) +}
\ No newline at end of file diff --git a/test/files/run/erasuretags_usage.scala b/test/files/run/erasuretags_usage.scala new file mode 100644 index 0000000000..16e53af071 --- /dev/null +++ b/test/files/run/erasuretags_usage.scala @@ -0,0 +1,12 @@ +object Test extends App { + def foo[T] = { + class MyErasureTag(_erasure: Class[_]) extends ErasureTag[T] { + def erasure: Class[T] = _erasure.asInstanceOf[Class[T]] + } + + implicit val tag = new MyErasureTag(classOf[Int]) + println(typeTag[T]) + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } +}
\ No newline at end of file diff --git a/test/files/run/existentials3.check b/test/files/run/existentials3-new.check index e2c9382ab4..66674fbbd6 100644 --- a/test/files/run/existentials3.check +++ b/test/files/run/existentials3-new.check @@ -1,24 +1,24 @@ -ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=f3
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=f4
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=f5
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS
-TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List
-ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
-ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=g3
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=g4
-ConcreteTypeTag[Test.ToS], t=RefinedType, s=g5
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS
-ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS
-TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List
-ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List
+ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton +ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar} +ConcreteTypeTag[Test.ToS], t=RefinedType, s=f3 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=f4 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=f5 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS +TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List +ConcreteTypeTag[Bar.type], t=AbstractTypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton +ConcreteTypeTag[Bar], t=AbstractTypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar} +ConcreteTypeTag[Test.ToS], t=RefinedType, s=g3 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=g4 +ConcreteTypeTag[Test.ToS], t=RefinedType, s=g5 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0 +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with Test.ToS +ConcreteTypeTag[$anon], t=AbstractTypeRef, s= <: B with A with Test.ToS +TypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List +ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List diff --git a/test/files/run/existentials3.scala b/test/files/run/existentials3-new.scala index d6d5612687..32129a04c6 100644 --- a/test/files/run/existentials3.scala +++ b/test/files/run/existentials3-new.scala @@ -38,8 +38,7 @@ object Test { def m[T: ConcreteTypeTag](x: T) = printTag(concreteTypeTag[T]) def m2[T: TypeTag](x: T) = printTag(typeTag[T]) - // manifests don't work for f10/g10 - // oh, they do now :) + // tags do work for f10/g10 def main(args: Array[String]): Unit = { m(f1) m(f2) diff --git a/test/files/run/existentials3-old.check b/test/files/run/existentials3-old.check new file mode 100644 index 0000000000..e166e53ba8 --- /dev/null +++ b/test/files/run/existentials3-old.check @@ -0,0 +1,22 @@ +_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with Test$ToS with scala.Product with scala.Serializable
+Object with Test$ToS
+Object with Test$ToS
+Object with Test$ToS
+scala.Function0[Object with Test$ToS]
+scala.Function0[Object with Test$ToS]
+_ <: Object with _ <: Object with Object with Test$ToS
+_ <: Object with _ <: Object with _ <: Object with Test$ToS
+scala.collection.immutable.List[Object with scala.collection.Seq[Int]]
+scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]]
+_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with Test$ToS with scala.Product with scala.Serializable
+Object with Test$ToS
+Object with Test$ToS
+Object with Test$ToS
+scala.Function0[Object with Test$ToS]
+scala.Function0[Object with Test$ToS]
+_ <: Object with _ <: Object with Object with Test$ToS
+_ <: Object with _ <: Object with _ <: Object with Test$ToS
+scala.collection.immutable.List[Object with scala.collection.Seq[Int]]
+scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]]
diff --git a/test/files/run/existentials3-old.scala b/test/files/run/existentials3-old.scala new file mode 100644 index 0000000000..944160ff12 --- /dev/null +++ b/test/files/run/existentials3-old.scala @@ -0,0 +1,73 @@ +object Test { + trait ToS { final override def toString = getClass.getName } + + def f1 = { case class Bar() extends ToS; Bar } + def f2 = { case class Bar() extends ToS; Bar() } + def f3 = { class Bar() extends ToS; object Bar extends ToS; Bar } + def f4 = { class Bar() extends ToS; new Bar() } + def f5 = { object Bar extends ToS; Bar } + def f6 = { () => { object Bar extends ToS ; Bar } } + def f7 = { val f = { () => { object Bar extends ToS ; Bar } } ; f } + + def f8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } } + def f9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } } + + def f10 = { class A { type T1 } ; List[A#T1]() } + def f11 = { abstract class A extends Seq[Int] ; List[A]() } + def f12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() } + + val g1 = { case class Bar() extends ToS; Bar } + val g2 = { case class Bar() extends ToS; Bar() } + val g3 = { class Bar() extends ToS; object Bar extends ToS; Bar } + val g4 = { class Bar() extends ToS; new Bar() } + val g5 = { object Bar extends ToS; Bar } + val g6 = { () => { object Bar extends ToS ; Bar } } + val g7 = { val f = { () => { object Bar extends ToS ; Bar } } ; f } + + val g8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } } + val g9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } } + + val g10 = { class A { type T1 } ; List[A#T1]() } + val g11 = { abstract class A extends Seq[Int] ; List[A]() } + val g12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() } + + def m[T: Manifest](x: T) = println(manifest[T]) + + // manifests don't work for f10/g10 + def main(args: Array[String]): Unit = { + m(f1) + m(f2) + m(f3) + m(f4) + m(f5) + m(f6) + m(f7) + m(f8) + m(f9) + // m(f10) + m(f11) + m(f12) + m(g1) + m(g2) + m(g3) + m(g4) + m(g5) + m(g6) + m(g7) + m(g8) + m(g9) + // m(g10) + m(g11) + m(g12) + } +} + +object Misc { + trait Bippy { def bippy = "I'm Bippy!" } + object o1 { + def f1 = { trait A extends Seq[U forSome { type U <: Bippy }] ; abstract class B extends A ; trait C extends B ; (null: C) } + def f2 = f1.head.bippy + } + def g1 = o1.f1 _ + def g2 = o1.f2 _ +} diff --git a/test/files/run/getClassTest.check b/test/files/run/getClassTest-new.check index 94e86c3889..94e86c3889 100644 --- a/test/files/run/getClassTest.check +++ b/test/files/run/getClassTest-new.check diff --git a/test/files/run/getClassTest-new.scala b/test/files/run/getClassTest-new.scala new file mode 100644 index 0000000000..89778ca2d3 --- /dev/null +++ b/test/files/run/getClassTest-new.scala @@ -0,0 +1,66 @@ +class AnyVals { + def f1 = (5: Any).getClass + def f2 = (5: AnyVal).getClass + def f3 = 5.getClass + def f4 = (5: java.lang.Integer).getClass + def f5 = (5.asInstanceOf[AnyRef]).getClass + + // scalap says: + // + // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f2 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f3 : java.lang.Class[scala.Int] = { /* compiled code */ } + // def f4 : java.lang.Class[?0] forSome {type ?0 <: java.lang.Integer} = { /* compiled code */ } + // def f5 : java.lang.Class[?0] forSome {type ?0 <: scala.AnyRef} = { /* compiled code */ } + // + // java generic signature says: + // + // f1: java.lang.Class<?> + // f2: java.lang.Class<?> + // f3: java.lang.Class<java.lang.Object> + // f4: java.lang.Class<? extends java.lang.Integer> + // f5: java.lang.Class<?> +} + +class AnyRefs { + class A + class B extends A + + def f1 = (new B: Any).getClass().newInstance() + def f2 = (new B: AnyRef).getClass().newInstance() + def f3 = (new B: A).getClass().newInstance() + def f4 = (new B: B).getClass().newInstance() + + def f0[T >: B] = (new B: T).getClass().newInstance() + + def f5 = f0[Any] + def f6 = f0[AnyRef] + def f7 = f0[A] + def f8 = f0[B] +} + +class MoreAnyRefs { + trait A + trait B + + // don't leak anon/refinements + def f1 = (new A with B { }).getClass() + def f2 = (new B with A { }).getClass() + def f3 = (new { def bippy() = 5 }).getClass() + def f4 = (new A { def bippy() = 5 }).getClass() +} + +object Test { + def returnTypes[T: ClassTag] = ( + classTag[T].erasure.getMethods.toList + filter (_.getName startsWith "f") + sortBy (_.getName) + map (m => m.getName + ": " + m.getGenericReturnType.toString) + ) + + def main(args: Array[String]): Unit = { + returnTypes[AnyVals] foreach println + returnTypes[AnyRefs] foreach println + returnTypes[MoreAnyRefs] foreach println + } +} diff --git a/test/files/run/getClassTest-old.check b/test/files/run/getClassTest-old.check new file mode 100644 index 0000000000..94e86c3889 --- /dev/null +++ b/test/files/run/getClassTest-old.check @@ -0,0 +1,18 @@ +f1: java.lang.Class<?> +f2: java.lang.Class<?> +f3: java.lang.Class<java.lang.Object> +f4: java.lang.Class<? extends java.lang.Integer> +f5: java.lang.Class<?> +f0: T +f1: class java.lang.Object +f2: class java.lang.Object +f3: class AnyRefs$A +f4: class AnyRefs$B +f5: class java.lang.Object +f6: class java.lang.Object +f7: class AnyRefs$A +f8: class AnyRefs$B +f1: java.lang.Class<? extends MoreAnyRefs$A> +f2: java.lang.Class<? extends MoreAnyRefs$B> +f3: java.lang.Class<?> +f4: java.lang.Class<? extends MoreAnyRefs$A> diff --git a/test/files/run/getClassTest.scala b/test/files/run/getClassTest-old.scala index 2485cd2c71..951cc8d931 100644 --- a/test/files/run/getClassTest.scala +++ b/test/files/run/getClassTest-old.scala @@ -4,7 +4,7 @@ class AnyVals { def f3 = 5.getClass def f4 = (5: java.lang.Integer).getClass def f5 = (5.asInstanceOf[AnyRef]).getClass - + // scalap says: // // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } @@ -19,18 +19,18 @@ class AnyVals { // f2: java.lang.Class<?> // f3: java.lang.Class<java.lang.Object> // f4: java.lang.Class<? extends java.lang.Integer> - // f5: java.lang.Class<?> + // f5: java.lang.Class<?> } class AnyRefs { class A class B extends A - + def f1 = (new B: Any).getClass().newInstance() def f2 = (new B: AnyRef).getClass().newInstance() def f3 = (new B: A).getClass().newInstance() def f4 = (new B: B).getClass().newInstance() - + def f0[T >: B] = (new B: T).getClass().newInstance() def f5 = f0[Any] @@ -52,7 +52,7 @@ class MoreAnyRefs { object Test { def returnTypes[T: Manifest] = ( - manifest[T].erasure.getMethods.toList + manifest[T].erasure.getMethods.toList filter (_.getName startsWith "f") sortBy (_.getName) map (m => m.getName + ": " + m.getGenericReturnType.toString) diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.check b/test/files/run/interop_classmanifests_arepartially_typetags.check new file mode 100644 index 0000000000..3dfcdccbec --- /dev/null +++ b/test/files/run/interop_classmanifests_arepartially_typetags.check @@ -0,0 +1,6 @@ +T
+int
+T
+class java.lang.String
+T
+class [I
diff --git a/test/files/run/interop_classmanifests_arepartially_typetags.scala b/test/files/run/interop_classmanifests_arepartially_typetags.scala new file mode 100644 index 0000000000..9bc1f32e86 --- /dev/null +++ b/test/files/run/interop_classmanifests_arepartially_typetags.scala @@ -0,0 +1,10 @@ +object Test extends App { + def classManifestIspartiallyTypeTag[T: ClassManifest] = { + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } + + classManifestIspartiallyTypeTag[Int] + classManifestIspartiallyTypeTag[String] + classManifestIspartiallyTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_classtags_are_classmanifests.check b/test/files/run/interop_classtags_are_classmanifests.check new file mode 100644 index 0000000000..02393dff23 --- /dev/null +++ b/test/files/run/interop_classtags_are_classmanifests.check @@ -0,0 +1,6 @@ +Int
+java.lang.String
+Array[Int]
+Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_classtags_are_classmanifests.scala b/test/files/run/interop_classtags_are_classmanifests.scala new file mode 100644 index 0000000000..309c99a3f5 --- /dev/null +++ b/test/files/run/interop_classtags_are_classmanifests.scala @@ -0,0 +1,17 @@ +object Test extends App { + def arrayTagIsClassManifest[T: ArrayTag] = { + println(classManifest[T]) + } + + arrayTagIsClassManifest[Int] + arrayTagIsClassManifest[String] + arrayTagIsClassManifest[Array[Int]] + + def classTagIsClassManifest[T: ClassTag] = { + println(classManifest[T]) + } + + classTagIsClassManifest[Int] + classTagIsClassManifest[String] + classTagIsClassManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.check b/test/files/run/interop_concretetypetags_are_classmanifests.check new file mode 100644 index 0000000000..c59e92d4eb --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_classmanifests.check @@ -0,0 +1,3 @@ +Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_concretetypetags_are_classmanifests.scala b/test/files/run/interop_concretetypetags_are_classmanifests.scala new file mode 100644 index 0000000000..b578d7e626 --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_classmanifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def concreteTypeTagIsClassManifest[T: ConcreteTypeTag] = { + println(classManifest[T]) + } + + concreteTypeTagIsClassManifest[Int] + concreteTypeTagIsClassManifest[String] + concreteTypeTagIsClassManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_concretetypetags_are_manifests.check b/test/files/run/interop_concretetypetags_are_manifests.check new file mode 100644 index 0000000000..c59e92d4eb --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_manifests.check @@ -0,0 +1,3 @@ +Int
+java.lang.String
+Array[Int]
diff --git a/test/files/run/interop_concretetypetags_are_manifests.scala b/test/files/run/interop_concretetypetags_are_manifests.scala new file mode 100644 index 0000000000..731410bc10 --- /dev/null +++ b/test/files/run/interop_concretetypetags_are_manifests.scala @@ -0,0 +1,9 @@ +object Test extends App { + def concreteTypeTagIsManifest[T: ConcreteTypeTag] = { + println(manifest[T]) + } + + concreteTypeTagIsManifest[Int] + concreteTypeTagIsManifest[String] + concreteTypeTagIsManifest[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_manifests_are_classtags.check b/test/files/run/interop_manifests_are_classtags.check new file mode 100644 index 0000000000..07ff6b984a --- /dev/null +++ b/test/files/run/interop_manifests_are_classtags.check @@ -0,0 +1,24 @@ +Int
+Int
+List()
+List(0, 0, 0, 0, 0)
+java.lang.String
+java.lang.String
+List()
+List(null, null, null, null, null)
+Array[Int]
+Array[Int]
+List()
+List(null, null, null, null, null)
+Int
+Int
+List()
+List(0, 0, 0, 0, 0)
+java.lang.String
+java.lang.String
+List()
+List(null, null, null, null, null)
+Array[Int]
+Array[Int]
+List()
+List(null, null, null, null, null)
diff --git a/test/files/run/interop_manifests_are_classtags.scala b/test/files/run/interop_manifests_are_classtags.scala new file mode 100644 index 0000000000..582cea3467 --- /dev/null +++ b/test/files/run/interop_manifests_are_classtags.scala @@ -0,0 +1,23 @@ +object Test extends App { + def classManifestIsClassTag[T: ClassManifest] = { + println(arrayTag[T]) + println(erasureTag[T]) + println(Array[T]().toList) + println(new Array[T](5).toList) + } + + classManifestIsClassTag[Int] + classManifestIsClassTag[String] + classManifestIsClassTag[Array[Int]] + + def manifestIsClassTag[T: Manifest] = { + println(arrayTag[T]) + println(erasureTag[T]) + println(Array[T]().toList) + println(new Array[T](5).toList) + } + + manifestIsClassTag[Int] + manifestIsClassTag[String] + manifestIsClassTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_manifests_are_concretetypetags.check b/test/files/run/interop_manifests_are_concretetypetags.check new file mode 100644 index 0000000000..edab85ecf1 --- /dev/null +++ b/test/files/run/interop_manifests_are_concretetypetags.check @@ -0,0 +1,6 @@ +Int +int +String +class java.lang.String +Array[Int] +class [I diff --git a/test/files/run/interop_manifests_are_concretetypetags.scala b/test/files/run/interop_manifests_are_concretetypetags.scala new file mode 100644 index 0000000000..0b82a56d0a --- /dev/null +++ b/test/files/run/interop_manifests_are_concretetypetags.scala @@ -0,0 +1,10 @@ +object Test extends App { + def manifestIsConcreteTypeTag[T: Manifest] = { + println(concreteTypeTag[T].tpe) + println(concreteTypeTag[T].erasure) + } + + manifestIsConcreteTypeTag[Int] + manifestIsConcreteTypeTag[String] + manifestIsConcreteTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/interop_manifests_are_typetags.check b/test/files/run/interop_manifests_are_typetags.check new file mode 100644 index 0000000000..edab85ecf1 --- /dev/null +++ b/test/files/run/interop_manifests_are_typetags.check @@ -0,0 +1,6 @@ +Int +int +String +class java.lang.String +Array[Int] +class [I diff --git a/test/files/run/interop_manifests_are_typetags.scala b/test/files/run/interop_manifests_are_typetags.scala new file mode 100644 index 0000000000..03a7b7b6d5 --- /dev/null +++ b/test/files/run/interop_manifests_are_typetags.scala @@ -0,0 +1,10 @@ +object Test extends App { + def manifestIsTypeTag[T: Manifest] = { + println(typeTag[T].tpe) + println(typeTag[T].erasure) + } + + manifestIsTypeTag[Int] + manifestIsTypeTag[String] + manifestIsTypeTag[Array[Int]] +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index a1f124f790..3de9367994 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -4,13 +4,6 @@ object Macros { def impl_with_macros_enabled(c: Context) = { import c.mirror._ - // todo. doesn't work. why? - //val mrPkg = staticModule("scala.reflect.package") - //val mrSym = selectTerm(mrPkg, "mirror") - //val NullaryMethodType(mrTpe) = mrSym.typeSignature - //val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) - //val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) - val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) val tree1 = Apply(Select(mr, newTermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check new file mode 100644 index 0000000000..02da6ad0c7 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -0,0 +1,5 @@ +{
+ val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
+ $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int])))
+}
+mr.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/macro-typecheck-macrosdisabled2.flags b/test/files/run/macro-typecheck-macrosdisabled2.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala new file mode 100644 index 0000000000..1b840a6204 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -0,0 +1,29 @@ +import scala.reflect.makro.Context + +object Macros { + def impl_with_macros_enabled(c: Context) = { + import c.mirror._ + + val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) + val tree1 = Apply(Select(mr, newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) + c.literal(ttree1.toString) + } + + def foo_with_macros_enabled = macro impl_with_macros_enabled + + def impl_with_macros_disabled(c: Context) = { + import c.mirror._ + + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) + c.literal(ttree2.toString) + } + + def foo_with_macros_disabled = macro impl_with_macros_disabled +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala new file mode 100644 index 0000000000..bdba39195b --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled2/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo_with_macros_enabled) + println(Macros.foo_with_macros_disabled) +}
\ No newline at end of file diff --git a/test/files/run/manifests-new.scala b/test/files/run/manifests-new.scala new file mode 100644 index 0000000000..4485ce9124 --- /dev/null +++ b/test/files/run/manifests-new.scala @@ -0,0 +1,147 @@ +object Test +{ + object Variances extends Enumeration { + val CO, IN, CONTRA = Value + } + import Variances.{ CO, IN, CONTRA } + + object SubtypeRelationship extends Enumeration { + val NONE, SAME, SUB, SUPER = Value + } + import SubtypeRelationship.{ NONE, SAME, SUB, SUPER } + + class VarianceTester[T, U, CC[_]](expected: Variances.Value)( + implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) { + + def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) + def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe) + + def isUnrelated = typeCompare[T, U] == NONE + def isSame = typeCompare[T, U] == SAME + def isSub = typeCompare[T, U] == SUB + def isSuper = typeCompare[T, U] == SUPER + + def showsCovariance = (elements == containers) + def showsContravariance = (elements == containers.reverse) + def showsInvariance = containers forall (_ == isSame) + + def allContainerVariances = List(showsCovariance, showsInvariance, showsContravariance) + + def showsExpectedVariance = + if (isUnrelated) allContainerVariances forall (_ == false) + else if (isSame) allContainerVariances forall (_ == true) + else expected match { + case CO => showsCovariance && !showsContravariance && !showsInvariance + case IN => showsInvariance && !showsCovariance && !showsContravariance + case CONTRA => showsContravariance && !showsCovariance && !showsInvariance + } + } + + def showsCovariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) = + new VarianceTester[T, U, CC](CO) showsExpectedVariance + + def showsInvariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) = + new VarianceTester[T, U, CC](IN) showsExpectedVariance + + def showsContravariance[T, U, CC[_]](implicit ev1: TypeTag[T], ev2: TypeTag[U], ev3: TypeTag[CC[T]], ev4: TypeTag[CC[U]]) = + new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance + + def typeCompare[T, U](implicit ev1: TypeTag[T], ev2: TypeTag[U]) = (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match { + case (true, true) => SAME + case (true, false) => SUB + case (false, true) => SUPER + case (false, false) => NONE + } + + def assertAnyRef[T: TypeTag] = List( + typeTag[T].tpe <:< typeTag[Any].tpe, + typeTag[T].tpe <:< typeTag[AnyRef].tpe, + !(typeTag[T].tpe <:< typeTag[AnyVal].tpe) + ) foreach (assert(_, "assertAnyRef")) + + def assertAnyVal[T: TypeTag] = List( + typeTag[T].tpe <:< typeTag[Any].tpe, + !(typeTag[T].tpe <:< typeTag[AnyRef].tpe), + typeTag[T].tpe <:< typeTag[AnyVal].tpe + ) foreach (assert(_, "assertAnyVal")) + + def assertSameType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SAME, "assertSameType") + def assertSuperType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SUPER, "assertSuperType") + def assertSubType[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == SUB, "assertSubType") + def assertNoRelationship[T: TypeTag, U: TypeTag] = assert(typeCompare[T, U] == NONE, "assertNoRelationship") + + def testVariancesVia[T: TypeTag, U: TypeTag] = assert( + typeCompare[T, U] == SUB && + showsCovariance[T, U, List] && + showsInvariance[T, U, Set], + "testVariancesVia" + ) + + def runAllTests = { + assertAnyVal[AnyVal] + assertAnyVal[Unit] + assertAnyVal[Int] + assertAnyVal[Double] + assertAnyVal[Boolean] + assertAnyVal[Char] + + assertAnyRef[AnyRef] + assertAnyRef[java.lang.Object] + assertAnyRef[java.lang.Integer] + assertAnyRef[java.lang.Double] + assertAnyRef[java.lang.Boolean] + assertAnyRef[java.lang.Character] + assertAnyRef[String] + assertAnyRef[scala.List[String]] + assertAnyRef[scala.List[_]] + + // variance doesn't work yet + // testVariancesVia[String, Any] + // testVariancesVia[String, AnyRef] + + assertSubType[List[String], List[Any]] + assertSubType[List[String], List[AnyRef]] + assertNoRelationship[List[String], List[AnyVal]] + + assertSubType[List[Int], List[Any]] + assertSubType[List[Int], List[AnyVal]] + assertNoRelationship[List[Int], List[AnyRef]] + + // Nothing + assertSubType[Nothing, Any] + assertSubType[Nothing, AnyVal] + assertSubType[Nothing, AnyRef] + assertSubType[Nothing, String] + assertSubType[Nothing, List[String]] + assertSubType[Nothing, Null] + assertSameType[Nothing, Nothing] + + // Null + assertSubType[Null, Any] + assertNoRelationship[Null, AnyVal] + assertSubType[Null, AnyRef] + assertSubType[Null, String] + assertSubType[Null, List[String]] + assertSameType[Null, Null] + assertSuperType[Null, Nothing] + + // Any + assertSameType[Any, Any] + assertSuperType[Any, AnyVal] + assertSuperType[Any, AnyRef] + assertSuperType[Any, String] + assertSuperType[Any, List[String]] + assertSuperType[Any, Null] + assertSuperType[Any, Nothing] + + // Misc unrelated types + assertNoRelationship[Unit, AnyRef] + assertNoRelationship[Unit, Int] + assertNoRelationship[Int, Long] + assertNoRelationship[Boolean, String] + assertNoRelationship[List[Boolean], List[String]] + assertNoRelationship[Set[Boolean], Set[String]] + } + + def main(args: Array[String]): Unit = runAllTests +} diff --git a/test/files/run/manifests.scala b/test/files/run/manifests-old.scala index 2d64bf18a9..621689a254 100644 --- a/test/files/run/manifests.scala +++ b/test/files/run/manifests-old.scala @@ -13,8 +13,8 @@ object Test class VarianceTester[T, U, CC[_]](expected: Variances.Value)( implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) { - def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) - def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe) + def elements = List(ev1 <:< ev2, ev2 <:< ev1) + def containers = List(ev3 <:< ev4, ev4 <:< ev3) def isUnrelated = typeCompare[T, U] == NONE def isSame = typeCompare[T, U] == SAME @@ -46,25 +46,23 @@ object Test def showsContravariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance - def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = { - (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match { - case (true, true) => SAME - case (true, false) => SUB - case (false, true) => SUPER - case (false, false) => NONE - } + def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = (ev1 <:< ev2, ev2 <:< ev1) match { + case (true, true) => SAME + case (true, false) => SUB + case (false, true) => SUPER + case (false, false) => NONE } def assertAnyRef[T: Manifest] = List( - manifest[T].tpe <:< manifest[Any].tpe, - manifest[T].tpe <:< manifest[AnyRef].tpe, - !(manifest[T].tpe <:< manifest[AnyVal].tpe) + manifest[T] <:< manifest[Any], + manifest[T] <:< manifest[AnyRef], + !(manifest[T] <:< manifest[AnyVal]) ) foreach (assert(_, "assertAnyRef")) def assertAnyVal[T: Manifest] = List( - manifest[T].tpe <:< manifest[Any].tpe, - !(manifest[T].tpe <:< manifest[AnyRef].tpe), - manifest[T].tpe <:< manifest[AnyVal].tpe + manifest[T] <:< manifest[Any], + !(manifest[T] <:< manifest[AnyRef]), + manifest[T] <:< manifest[AnyVal] ) foreach (assert(_, "assertAnyVal")) def assertSameType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SAME, "assertSameType") @@ -146,4 +144,4 @@ object Test } def main(args: Array[String]): Unit = runAllTests -} +}
\ No newline at end of file diff --git a/test/files/run/patmat_unapp_abstype.check b/test/files/run/patmat_unapp_abstype-new.check index 72239d16cd..72239d16cd 100644 --- a/test/files/run/patmat_unapp_abstype.check +++ b/test/files/run/patmat_unapp_abstype-new.check diff --git a/test/files/run/patmat_unapp_abstype.flags b/test/files/run/patmat_unapp_abstype-new.flags index ba80cad69b..ba80cad69b 100644 --- a/test/files/run/patmat_unapp_abstype.flags +++ b/test/files/run/patmat_unapp_abstype-new.flags diff --git a/test/files/run/patmat_unapp_abstype.scala b/test/files/run/patmat_unapp_abstype-new.scala index 45496f08a2..45496f08a2 100644 --- a/test/files/run/patmat_unapp_abstype.scala +++ b/test/files/run/patmat_unapp_abstype-new.scala diff --git a/test/files/run/patmat_unapp_abstype-old.check b/test/files/run/patmat_unapp_abstype-old.check new file mode 100644 index 0000000000..72239d16cd --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-old.check @@ -0,0 +1,4 @@ +TypeRef +none of the above +Bar +Foo diff --git a/test/files/run/patmat_unapp_abstype-old.flags b/test/files/run/patmat_unapp_abstype-old.flags new file mode 100644 index 0000000000..ba80cad69b --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-old.flags @@ -0,0 +1 @@ +-Xoldpatmat diff --git a/test/files/run/patmat_unapp_abstype-old.scala b/test/files/run/patmat_unapp_abstype-old.scala new file mode 100644 index 0000000000..45496f08a2 --- /dev/null +++ b/test/files/run/patmat_unapp_abstype-old.scala @@ -0,0 +1,83 @@ +// abstract types and extractors, oh my! +trait TypesAPI { + trait Type + + // an alternative fix (implemented in the virtual pattern matcher, is to replace the isInstanceOf by a manifest-based run-time test) + // that's what typeRefMani is for + type TypeRef <: Type //; implicit def typeRefMani: Manifest[TypeRef] + val TypeRef: TypeRefExtractor; trait TypeRefExtractor { + def apply(x: Int): TypeRef + def unapply(x: TypeRef): Option[(Int)] + } + + // just for illustration, should follow the same pattern as TypeRef + case class MethodType(n: Int) extends Type +} + +// user should not be exposed to the implementation +trait TypesUser extends TypesAPI { + def shouldNotCrash(tp: Type): Unit = { + tp match { + case TypeRef(x) => println("TypeRef") + // the above checks tp.isInstanceOf[TypeRef], which is erased to tp.isInstanceOf[Type] + // before calling TypeRef.unapply(tp), which will then crash unless tp.isInstanceOf[TypesImpl#TypeRef] (which is not implied by tp.isInstanceOf[Type]) + // tp.isInstanceOf[TypesImpl#TypeRef] is equivalent to classOf[TypesImpl#TypeRef].isAssignableFrom(tp.getClass) + // this is equivalent to manifest + // it is NOT equivalent to manifest[Type] <:< typeRefMani + case MethodType(x) => println("MethodType") + case _ => println("none of the above") + } + } +} + +trait TypesImpl extends TypesAPI { + object TypeRef extends TypeRefExtractor // this will have a bridged unapply(x: Type) = unapply(x.asInstanceOf[TypeRef]) + case class TypeRef(n: Int) extends Type // this has a bridge from TypesAPI#Type to TypesImpl#TypeRef + // --> the cast in the bridge will fail because the pattern matcher can't type test against the abstract types in TypesUser + //lazy val typeRefMani = manifest[TypeRef] +} + +trait Foos { + trait Bar + type Foo <: Bar + trait FooExtractor { + def unapply(foo: Foo): Option[Int] + } + val Foo: FooExtractor +} + +trait RealFoos extends Foos { + class Foo(val x: Int) extends Bar + object Foo extends FooExtractor { + def unapply(foo: Foo): Option[Int] = Some(foo.x) + } +} + +trait Intermed extends Foos { + def crash(bar: Bar): Unit = + bar match { + case Foo(x) => println("Foo") + case _ => println("Bar") + } +} + +object TestUnappStaticallyKnownSynthetic extends TypesImpl with TypesUser { + def test() = { + shouldNotCrash(TypeRef(10)) // should and does print "TypeRef" + // once #1697/#2337 are fixed, this should generate the correct output + shouldNotCrash(MethodType(10)) // should print "MethodType" but prints "none of the above" -- good one, pattern matcher! + } +} + +object TestUnappDynamicSynth extends RealFoos with Intermed { + case class FooToo(n: Int) extends Bar + def test() = { + crash(FooToo(10)) + crash(new Foo(5)) + } +} + +object Test extends App { + TestUnappStaticallyKnownSynthetic.test() + TestUnappDynamicSynth.test() +} diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2-new.check index 1b6e24ed20..b82ddbeaff 100644 --- a/test/files/run/primitive-sigs-2.check +++ b/test/files/run/primitive-sigs-2-new.check @@ -1,7 +1,7 @@ T<java.lang.Object>
List(A, char, class java.lang.Object)
a
-public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.api.TypeTags.scala.reflect.api.TypeTags$ConcreteTypeTag<T>)
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.ArrayTag<T>)
public float[] Arr.arr3(float[][])
public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[])
public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[])
diff --git a/test/files/run/primitive-sigs-2-new.scala b/test/files/run/primitive-sigs-2-new.scala new file mode 100644 index 0000000000..7e13014cb2 --- /dev/null +++ b/test/files/run/primitive-sigs-2-new.scala @@ -0,0 +1,31 @@ +import java.{ lang => jl } + +trait T[A] { + def f(): A +} +class C extends T[Char] { + def f(): Char = 'a' +} +class Arr { + def arr1(xs: Array[Int]): List[Int] = xs.toList + def arr2(xs: Array[jl.Character]): List[jl.Character] = xs.toList + def arr3(xss: Array[Array[Float]]): Array[Float] = xss map (_.sum) + def arr4[T: ArrayTag](xss: Array[Array[T]]): Array[T] = xss map (_.head) +} + +object Test { + val c1: Class[_] = classOf[T[_]] + val c2: Class[_] = classOf[C] + val c3: Class[_] = classOf[Arr] + + val c1m = c1.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) + val c2m = c2.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) + val c3m = c3.getDeclaredMethods.toList map (_.toGenericString) + + def main(args: Array[String]): Unit = { + println(c2.getGenericInterfaces.map(_.toString).sorted mkString " ") + println(c1m ++ c2m sorted) + println(new C f) + c3m.sorted foreach println + } +} diff --git a/test/files/run/primitive-sigs-2-old.check b/test/files/run/primitive-sigs-2-old.check new file mode 100644 index 0000000000..9132b4d8ae --- /dev/null +++ b/test/files/run/primitive-sigs-2-old.check @@ -0,0 +1,7 @@ +T<java.lang.Object>
+List(A, char, class java.lang.Object)
+a
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>)
+public float[] Arr.arr3(float[][])
+public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[])
+public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[])
diff --git a/test/files/run/primitive-sigs-2.scala b/test/files/run/primitive-sigs-2-old.scala index b7152f7e3d..b7152f7e3d 100644 --- a/test/files/run/primitive-sigs-2.scala +++ b/test/files/run/primitive-sigs-2-old.scala diff --git a/test/files/run/reflection-implClass-new.scala b/test/files/run/reflection-implClass-new.scala new file mode 100644 index 0000000000..27374f2106 --- /dev/null +++ b/test/files/run/reflection-implClass-new.scala @@ -0,0 +1,38 @@ +/** + * Tries to load a symbol for the `Foo$class` using Scala reflection. + * Since trait implementation classes do not get pickling information + * symbol for them should be created using fallback mechanism + * that exposes Java reflection information dressed up in + * a Scala symbol. + */ +object Test extends App with Outer { + import scala.reflect.mirror + + assert(mirror.classToSymbol(classTag[Foo].erasure).typeSignature.declaration(mirror.newTermName("bar")).typeSignature == + mirror.classToSymbol(classTag[Bar].erasure).typeSignature.declaration(mirror.newTermName("foo")).typeSignature) + + val s1 = implClass(classTag[Foo].erasure) + assert(s1 != mirror.NoSymbol) + assert(s1.typeSignature != mirror.NoType) + assert(s1.companionSymbol.typeSignature != mirror.NoType) + assert(s1.companionSymbol.typeSignature.declaration(mirror.newTermName("bar")) != mirror.NoSymbol) + val s2 = implClass(classTag[Bar].erasure) + assert(s2 != mirror.NoSymbol) + assert(s2.typeSignature != mirror.NoType) + assert(s2.companionSymbol.typeSignature != mirror.NoType) + assert(s2.companionSymbol.typeSignature.declaration(mirror.newTermName("foo")) != mirror.NoSymbol) + def implClass(clazz: Class[_]) = { + val implClass = Class.forName(clazz.getName + "$class") + mirror.classToSymbol(implClass) + } +} + +trait Foo { + def bar = 1 +} + +trait Outer { + trait Bar { + def foo = 1 + } +} diff --git a/test/files/run/reflection-implClass.scala b/test/files/run/reflection-implClass-old.scala index 7718b52f33..6583624d8b 100644 --- a/test/files/run/reflection-implClass.scala +++ b/test/files/run/reflection-implClass-old.scala @@ -1,5 +1,5 @@ -/** - * Tries to load a symbol for the `Foo$class` using Scala reflection. +/** + * Tries to load a symbol for the `Foo$class` using Scala reflection. * Since trait implementation classes do not get pickling information * symbol for them should be created using fallback mechanism * that exposes Java reflection information dressed up in diff --git a/test/files/run/reify_implicits.check b/test/files/run/reify_implicits-new.check index e3aeb20f6b..e3aeb20f6b 100644 --- a/test/files/run/reify_implicits.check +++ b/test/files/run/reify_implicits-new.check diff --git a/test/files/run/reify_implicits-new.scala b/test/files/run/reify_implicits-new.scala new file mode 100644 index 0000000000..69198391d1 --- /dev/null +++ b/test/files/run/reify_implicits-new.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + reify { + implicit def arrayWrapper[A : ArrayTag](x: Array[A]) = + new { + def sort(p: (A, A) => Boolean) = { + util.Sorting.stableSort(x, p); x + } + } + val x = Array(2, 3, 1, 4) + println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) + }.eval +} diff --git a/test/files/run/reify_implicits-old.check b/test/files/run/reify_implicits-old.check new file mode 100644 index 0000000000..e3aeb20f6b --- /dev/null +++ b/test/files/run/reify_implicits-old.check @@ -0,0 +1 @@ +x = List(1, 2, 3, 4) diff --git a/test/files/run/reify_implicits.scala b/test/files/run/reify_implicits-old.scala index 60971c3cfb..60971c3cfb 100644 --- a/test/files/run/reify_implicits.scala +++ b/test/files/run/reify_implicits-old.scala diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 1e7b6f0cd8..c509434116 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -1,32 +1,32 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** - -scala> // guarding against "error: reference to global is ambiguous" - -scala> global.emptyValDef // "it is imported twice in the same scope by ..." -res0: $r.global.emptyValDef.type = private val _ = _ - -scala> val tp = ArrayClass[scala.util.Random] // magic with manifests -tp: $r.global.Type = Array[scala.util.Random] - -scala> tp.memberType(Array_apply) // evidence -res1: $r.global.Type = (i: Int)scala.util.Random - -scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl -m: $r.treedsl.global.Match = -10 match { - case 5 => false - case _ => true -} - -scala> typed(m).tpe // typed is in scope -res2: $r.treedsl.global.Type = Boolean - -scala> +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :power
+** Power User mode enabled - BEEP WHIR GYVE **
+** :phase has been set to 'typer'. **
+** scala.tools.nsc._ has been imported **
+** global._, definitions._ also imported **
+** Try :help, :vals, power.<tab> **
+
+scala> // guarding against "error: reference to global is ambiguous"
+
+scala> global.emptyValDef // "it is imported twice in the same scope by ..."
+res0: $r.global.emptyValDef.type = private val _ = _
+
+scala> val tp = ArrayClass[scala.util.Random] // magic with tags
+tp: $r.global.Type = Array[scala.util.Random]
+
+scala> tp.memberType(Array_apply) // evidence
+res1: $r.global.Type = (i: Int)scala.util.Random
+
+scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl
+m: $r.treedsl.global.Match =
+10 match {
+ case 5 => false
+ case _ => true
+}
+
+scala> typed(m).tpe // typed is in scope
+res2: $r.treedsl.global.Type = Boolean
+
+scala>
diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala index 27da3df106..f7c88c63ff 100644 --- a/test/files/run/repl-power.scala +++ b/test/files/run/repl-power.scala @@ -5,10 +5,9 @@ object Test extends ReplTest { :power // guarding against "error: reference to global is ambiguous" global.emptyValDef // "it is imported twice in the same scope by ..." -val tp = ArrayClass[scala.util.Random] // magic with manifests +val tp = ArrayClass[scala.util.Random] // magic with tags tp.memberType(Array_apply) // evidence val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl typed(m).tpe // typed is in scope """.trim } - diff --git a/test/files/run/t0421.check b/test/files/run/t0421-new.check index cdcf042f19..cdcf042f19 100644 --- a/test/files/run/t0421.check +++ b/test/files/run/t0421-new.check diff --git a/test/files/run/t0421-new.scala b/test/files/run/t0421-new.scala new file mode 100644 index 0000000000..7de6b7f2c4 --- /dev/null +++ b/test/files/run/t0421-new.scala @@ -0,0 +1,30 @@ +// ticket #421 +object Test extends App { + + def transpose[A: ArrayTag](xss: Array[Array[A]]) = { + for (i <- Array.range(0, xss(0).length)) yield + for (xs <- xss) yield xs(i) + } + + def scalprod(xs: Array[Double], ys: Array[Double]) = { + var acc = 0.0 + for ((x, y) <- xs zip ys) acc = acc + x * y + acc + } + + def matmul(xss: Array[Array[Double]], yss: Array[Array[Double]]) = { + val ysst = transpose(yss) + val ysst1: Array[Array[Double]] = yss.transpose + assert(ysst.deep == ysst1.deep) + for (xs <- xss) yield + for (yst <- ysst) yield + scalprod(xs, yst) + } + + val a1 = Array(Array(0, 2, 4), Array(1, 3, 5)) + println(transpose(a1).deep.mkString("[", ",", "]")) + + println(matmul(Array(Array(2, 3)), Array(Array(5), Array(7))).deep.mkString("[", ",", "]")) + + println(matmul(Array(Array(4)), Array(Array(6, 8))).deep.mkString("[", ",", "]")) +} diff --git a/test/files/run/t0421-old.check b/test/files/run/t0421-old.check new file mode 100644 index 0000000000..cdcf042f19 --- /dev/null +++ b/test/files/run/t0421-old.check @@ -0,0 +1,3 @@ +[Array(0, 1),Array(2, 3),Array(4, 5)] +[Array(31.0)] +[Array(24.0, 32.0)] diff --git a/test/files/run/t0421.scala b/test/files/run/t0421-old.scala index 8d51013924..8d51013924 100644 --- a/test/files/run/t0421.scala +++ b/test/files/run/t0421-old.scala diff --git a/test/files/run/t0677-new.scala b/test/files/run/t0677-new.scala new file mode 100644 index 0000000000..bf7a3971dc --- /dev/null +++ b/test/files/run/t0677-new.scala @@ -0,0 +1,8 @@ +object Test extends App { + class X[T: ArrayTag] { + val a = Array.ofDim[T](3, 4) + } + val x = new X[String] + x.a(1)(2) = "hello" + assert(x.a(1)(2) == "hello") +} diff --git a/test/files/run/t0677.scala b/test/files/run/t0677-old.scala index 6c8a3a7e99..6c8a3a7e99 100644 --- a/test/files/run/t0677.scala +++ b/test/files/run/t0677-old.scala diff --git a/test/files/run/t1195.check b/test/files/run/t1195-new.check index 554e3fd03d..554e3fd03d 100644 --- a/test/files/run/t1195.check +++ b/test/files/run/t1195-new.check diff --git a/test/files/run/t1195.scala b/test/files/run/t1195-new.scala index 93b1dcbd07..6f28a4a167 100644 --- a/test/files/run/t1195.scala +++ b/test/files/run/t1195-new.scala @@ -7,7 +7,7 @@ object Test { val g1 = g() val h1 = h() - def m[T: Manifest](x: T) = println(manifest[T] + ", underlying = " + manifest[T].sym.typeSignature) + def m[T: TypeTag](x: T) = println(typeTag[T] + ", underlying = " + typeTag[T].sym.typeSignature) def main(args: Array[String]): Unit = { m(f) diff --git a/test/files/run/t1195-old.check b/test/files/run/t1195-old.check new file mode 100644 index 0000000000..eb60eceb17 --- /dev/null +++ b/test/files/run/t1195-old.check @@ -0,0 +1,6 @@ +_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with scala.Product with scala.Serializable
+Object with scala.Product with scala.Serializable
+_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
+_ <: Object with scala.Product with scala.Serializable
+Object with scala.Product with scala.Serializable
diff --git a/test/files/run/t1195-old.scala b/test/files/run/t1195-old.scala new file mode 100644 index 0000000000..b46a3b70f5 --- /dev/null +++ b/test/files/run/t1195-old.scala @@ -0,0 +1,26 @@ +object Test { + def f() = { case class Bar(x: Int); Bar } + def g() = { case class Bar(x: Int); Bar(5) } + def h() = { case object Bar ; Bar } + + val f1 = f() + val g1 = g() + val h1 = h() + + def m[T: Manifest](x: T) = println(manifest[T]) + + def main(args: Array[String]): Unit = { + m(f) + m(g) + m(h) + m(f1) + m(g1) + m(h1) + } +} + +class A1[T] { + class B1[U] { + def f = { case class D(x: Int) extends A1[String] ; new D(5) } + } +} diff --git a/test/files/run/t2236-new.scala b/test/files/run/t2236-new.scala new file mode 100644 index 0000000000..bbabe8e7d9 --- /dev/null +++ b/test/files/run/t2236-new.scala @@ -0,0 +1,17 @@ +class T[A](implicit val m:TypeTag[A]) +class Foo +class Bar extends T[Foo] +object Test extends App { + new Bar +} + +object EvidenceTest { + trait E[T] + trait A[T] { implicit val e: E[T] = null } + class B[T : E] extends A[T] { override val e = null } + + def f[T] { + implicit val e: E[T] = null + new B[T]{} + } +} diff --git a/test/files/run/t2236.scala b/test/files/run/t2236-old.scala index 64ed18c805..64ed18c805 100755..100644 --- a/test/files/run/t2236.scala +++ b/test/files/run/t2236-old.scala diff --git a/test/files/run/t2386-new.check b/test/files/run/t2386-new.check new file mode 100644 index 0000000000..98e226f946 --- /dev/null +++ b/test/files/run/t2386-new.check @@ -0,0 +1,2 @@ +a(0) = Array(1, 2)
+a(1) = Array("a", "b")
diff --git a/test/files/run/t2386-new.scala b/test/files/run/t2386-new.scala new file mode 100644 index 0000000000..15d1859759 --- /dev/null +++ b/test/files/run/t2386-new.scala @@ -0,0 +1,5 @@ +object Test extends App { + val a = Array(Array(1, 2), Array("a","b")) + println("a(0) = Array(" + (a(0) mkString ", ") + ")") + println("a(1) = Array(" + (a(1) map (s => "\"" + s + "\"") mkString ", ") + ")") +} diff --git a/test/files/run/t3507.check b/test/files/run/t3507-new.check index 6e4fa4170e..6e4fa4170e 100644 --- a/test/files/run/t3507.check +++ b/test/files/run/t3507-new.check diff --git a/test/files/run/t3507.scala b/test/files/run/t3507-new.scala index 3cdd40a881..c7a529e8b8 100644 --- a/test/files/run/t3507.scala +++ b/test/files/run/t3507-new.scala @@ -9,7 +9,7 @@ object Test extends App { var a: A = new A // mutable val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential - def mani[T: Manifest](x: T) = println(manifest[T]) + def mani[T: TypeTag](x: T) = println(typeTag[T]) mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier // --> _1 is not in scope here }
\ No newline at end of file diff --git a/test/files/run/t3758-old.scala b/test/files/run/t3758-old.scala new file mode 100644 index 0000000000..f00254afee --- /dev/null +++ b/test/files/run/t3758-old.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(classManifest[Array[String]].typeArguments contains classManifest[String]) + assert(classManifest[Array[Int]].typeArguments contains classManifest[Int]) + assert(classManifest[Array[Float]].typeArguments contains classManifest[Float]) + assert(manifest[Array[String]].typeArguments contains manifest[String]) + assert(manifest[Array[Int]].typeArguments contains manifest[Int]) + assert(manifest[Array[Float]].typeArguments contains manifest[Float]) + } +}
\ No newline at end of file diff --git a/test/files/run/t3758.check b/test/files/run/t3758.check deleted file mode 100644 index 9c6ab655a3..0000000000 --- a/test/files/run/t3758.check +++ /dev/null @@ -1,6 +0,0 @@ -List(String)
-List(Int)
-List(Float)
-List(String)
-List(Int)
-List(Float)
diff --git a/test/files/run/t3758.scala b/test/files/run/t3758.scala deleted file mode 100644 index 10bfb5724b..0000000000 --- a/test/files/run/t3758.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - println(classManifest[Array[String]].tpe.typeArguments) - println(classManifest[Array[Int]].tpe.typeArguments) - println(classManifest[Array[Float]].tpe.typeArguments) - println(manifest[Array[String]].tpe.typeArguments) - println(manifest[Array[Int]].tpe.typeArguments) - println(manifest[Array[Float]].tpe.typeArguments) - } -} diff --git a/test/files/run/t4110.check b/test/files/run/t4110-new.check index 28f220e1fe..28f220e1fe 100644 --- a/test/files/run/t4110.check +++ b/test/files/run/t4110-new.check diff --git a/test/files/run/t4110-new.scala b/test/files/run/t4110-new.scala new file mode 100644 index 0000000000..3285b82c61 --- /dev/null +++ b/test/files/run/t4110-new.scala @@ -0,0 +1,11 @@ +object Test extends App { + def inferredType[T : TypeTag](v : T) = println(typeTag[T]) + + trait A + trait B + + inferredType(new A with B) + + val name = new A with B + inferredType(name) +}
\ No newline at end of file diff --git a/test/files/run/t4110-old.check b/test/files/run/t4110-old.check new file mode 100644 index 0000000000..8b005989de --- /dev/null +++ b/test/files/run/t4110-old.check @@ -0,0 +1,2 @@ +Object with Test$A with Test$B +Object with Test$A with Test$B diff --git a/test/files/run/t4110.scala b/test/files/run/t4110-old.scala index 4bd377b73e..a42646ce52 100644 --- a/test/files/run/t4110.scala +++ b/test/files/run/t4110-old.scala @@ -3,7 +3,7 @@ object Test extends App { trait A trait B - + inferredType(new A with B) val name = new A with B diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check new file mode 100644 index 0000000000..271139b031 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -0,0 +1,5 @@ +{
+ val $mr: mr.type = mr;
+ $mr.Expr.apply[Array[Int]]($mr.Apply.apply($mr.Select.apply($mr.Select.apply($mr.Ident($mr.staticModule("scala")), $mr.newTermName("Array")), $mr.newTermName("apply")), scala.collection.immutable.List.apply[$mr.Literal]($mr.Literal.apply($mr.Constant.apply(2)))))($mr.ConcreteTypeTag.apply[Array[Int]]($mr.TypeRef.apply($mr.thisModuleType("scala"), $mr.staticClass("scala.Array"), scala.collection.immutable.List.apply[$mr.Type]($mr.staticClass("scala.Int").asTypeConstructor)), ScalaRunTime.this.arrayClass(classOf[scala.Int])))
+}
+mr.reify[Array[Int]](scala.Array.apply(2))
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala new file mode 100644 index 0000000000..b4c76d0600 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox() + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror) + + val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) + println(ttree1) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Apply(Select(Ident(newTermName("scala")), newTermName("Array")), List(Literal(Constant(2)))))) + val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) + println(ttree2) +} diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check index 62fcb481ae..f124aa6a35 100644 --- a/test/files/run/typetags_core.check +++ b/test/files/run/typetags_core.check @@ -1,30 +1,32 @@ -true
-ConcreteTypeTag[Byte]
-true
-ConcreteTypeTag[Short]
-true
-ConcreteTypeTag[Char]
-true
-ConcreteTypeTag[Int]
-true
-ConcreteTypeTag[Long]
-true
-ConcreteTypeTag[Float]
-true
-ConcreteTypeTag[Double]
-true
-ConcreteTypeTag[Boolean]
-true
-ConcreteTypeTag[Unit]
-true
-ConcreteTypeTag[Any]
-true
-ConcreteTypeTag[Object]
-true
-ConcreteTypeTag[AnyVal]
-true
-ConcreteTypeTag[AnyRef]
-true
-ConcreteTypeTag[Null]
-true
-ConcreteTypeTag[Nothing]
+true +ConcreteTypeTag[Byte] +true +ConcreteTypeTag[Short] +true +ConcreteTypeTag[Char] +true +ConcreteTypeTag[Int] +true +ConcreteTypeTag[Long] +true +ConcreteTypeTag[Float] +true +ConcreteTypeTag[Double] +true +ConcreteTypeTag[Boolean] +true +ConcreteTypeTag[Unit] +true +ConcreteTypeTag[Any] +true +ConcreteTypeTag[Object] +true +ConcreteTypeTag[AnyVal] +true +ConcreteTypeTag[AnyRef] +true +ConcreteTypeTag[Null] +true +ConcreteTypeTag[Nothing] +true +ConcreteTypeTag[String] diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala index 883c54b9a8..7d6be16379 100644 --- a/test/files/run/typetags_core.scala +++ b/test/files/run/typetags_core.scala @@ -29,4 +29,6 @@ object Test extends App { println(implicitly[TypeTag[Null]]) println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing) println(implicitly[TypeTag[Nothing]]) + println(implicitly[TypeTag[String]] eq TypeTag.String) + println(implicitly[TypeTag[String]]) }
\ No newline at end of file diff --git a/test/files/run/typetags_multi.check b/test/files/run/typetags_multi.check new file mode 100644 index 0000000000..613106985c --- /dev/null +++ b/test/files/run/typetags_multi.check @@ -0,0 +1,5 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[Array[Int]]
+ConcreteTypeTag[Array[Array[Int]]]
+ConcreteTypeTag[Array[Array[Array[Int]]]]
+ConcreteTypeTag[Array[Array[Array[Array[Int]]]]]
diff --git a/test/files/run/typetags_multi.scala b/test/files/run/typetags_multi.scala new file mode 100644 index 0000000000..868edc2b2a --- /dev/null +++ b/test/files/run/typetags_multi.scala @@ -0,0 +1,7 @@ +object Test extends App { + println(typeTag[Int]) + println(typeTag[Array[Int]]) + println(typeTag[Array[Array[Int]]]) + println(typeTag[Array[Array[Array[Int]]]]) + println(typeTag[Array[Array[Array[Array[Int]]]]]) +}
\ No newline at end of file |