summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmarking/ParCtrie-size.scala34
-rw-r--r--test/files/buildmanager/t2652/t2652.check2
-rw-r--r--test/files/neg/t5429.check132
-rw-r--r--test/files/neg/t5429.scala93
-rw-r--r--test/files/pos/spec-Function1.scala2
-rw-r--r--test/files/pos/spec-groups.scala65
-rw-r--r--test/files/pos/specialize10.scala7
-rw-r--r--test/files/run/ctries/concmap.scala19
-rw-r--r--test/files/run/ctries/iterator.scala10
-rw-r--r--test/files/run/interpolationMultiline1.check26
-rw-r--r--test/files/run/interpolationMultiline1.flags1
-rw-r--r--test/files/run/interpolationMultiline1.scala26
-rw-r--r--test/files/run/interpolationMultiline2.check26
-rw-r--r--test/files/run/interpolationMultiline2.flags1
-rw-r--r--test/files/run/interpolationMultiline2.scala21
-rw-r--r--test/files/run/t3575.check4
-rw-r--r--test/files/run/t3575.scala12
-rw-r--r--test/files/run/t4770.check2
-rw-r--r--test/files/run/t4770.scala15
-rw-r--r--test/files/run/t4794.check2
-rw-r--r--test/files/specialized/arrays-traits.check8
-rw-r--r--test/files/specialized/arrays-traits.scala17
-rw-r--r--test/files/specialized/arrays.check6
-rw-r--r--test/files/speclib/instrumented.jar.desired.sha12
-rw-r--r--test/instrumented/boxes.patch29
-rw-r--r--test/instrumented/library/scala/runtime/BoxesRunTime.java116
-rw-r--r--test/instrumented/library/scala/runtime/ScalaRunTime.scala255
-rwxr-xr-xtest/instrumented/mkinstrumented46
-rwxr-xr-xtest/instrumented/mkinstrumented.sh51
-rw-r--r--test/instrumented/srt.patch23
-rw-r--r--test/pending/pos/t4012.scala7
-rw-r--r--test/pending/pos/t4541.scala10
-rw-r--r--test/pending/pos/t4786.scala24
-rw-r--r--test/pending/pos/t4790.scala4
-rw-r--r--test/pending/run/t4511.scala10
-rw-r--r--test/pending/run/t4971.scala16
-rw-r--r--test/pending/run/t5284.scala14
37 files changed, 917 insertions, 221 deletions
diff --git a/test/benchmarking/ParCtrie-size.scala b/test/benchmarking/ParCtrie-size.scala
new file mode 100644
index 0000000000..5a6191fb62
--- /dev/null
+++ b/test/benchmarking/ParCtrie-size.scala
@@ -0,0 +1,34 @@
+
+
+
+
+import collection.parallel.mutable.ParCtrie
+
+
+
+object Size extends testing.Benchmark {
+ val length = sys.props("length").toInt
+ val par = sys.props("par").toInt
+ var parctrie = ParCtrie((0 until length) zip (0 until length): _*)
+
+ collection.parallel.ForkJoinTasks.defaultForkJoinPool.setParallelism(par)
+
+ def run = {
+ parctrie.size
+ }
+
+ var iteration = 0
+
+ override def tearDown() {
+ iteration += 1
+ if (iteration % 4 == 0) parctrie = ParCtrie((0 until length) zip (0 until length): _*)
+ }
+
+}
+
+
+
+
+
+
+
diff --git a/test/files/buildmanager/t2652/t2652.check b/test/files/buildmanager/t2652/t2652.check
index 071281c6ff..b84c80205e 100644
--- a/test/files/buildmanager/t2652/t2652.check
+++ b/test/files/buildmanager/t2652/t2652.check
@@ -3,7 +3,7 @@ compiling Set(A.scala, B.scala)
Changes: Map()
builder > A.scala
compiling Set(A.scala)
-Changes: Map(class A -> List(Added(Definition(A.x$mBc$sp)), Added(Definition(A.x$mCc$sp)), Added(Definition(A.x$mDc$sp)), Added(Definition(A.x$mFc$sp)), Added(Definition(A.x$mIc$sp)), Added(Definition(A.x$mJc$sp)), Added(Definition(A.x$mSc$sp)), Added(Definition(A.x$mVc$sp)), Added(Definition(A.x$mZc$sp)), Changed(Definition(A.x))[method x changed from [T](t: T)T to [T](t: T)T flags: <method> <triedcooking>]))
+Changes: Map(class A -> List(Added(Definition(A.x$mBc$sp)), Added(Definition(A.x$mCc$sp)), Added(Definition(A.x$mDc$sp)), Added(Definition(A.x$mFc$sp)), Added(Definition(A.x$mIc$sp)), Added(Definition(A.x$mJc$sp)), Added(Definition(A.x$mLc$sp)), Added(Definition(A.x$mSc$sp)), Added(Definition(A.x$mVc$sp)), Added(Definition(A.x$mZc$sp)), Changed(Definition(A.x))[method x changed from [T](t: T)T to [T](t: T)T flags: <method> <triedcooking>]))
invalidate B.scala because it references changed definition [Changed(Definition(A.x))[method x changed from [T](t: T)T to [T](t: T)T flags: <method> <triedcooking>]]
compiling Set(B.scala)
Changes: Map(object B -> List())
diff --git a/test/files/neg/t5429.check b/test/files/neg/t5429.check
new file mode 100644
index 0000000000..1b89c59587
--- /dev/null
+++ b/test/files/neg/t5429.check
@@ -0,0 +1,132 @@
+t5429.scala:20: error: overriding value value in class A of type Int;
+ object value needs `override' modifier
+ object value // fail
+ ^
+t5429.scala:21: error: overriding lazy value lazyvalue in class A of type Int;
+ object lazyvalue needs `override' modifier
+ object lazyvalue // fail
+ ^
+t5429.scala:22: error: overriding method nullary in class A of type => Int;
+ object nullary needs `override' modifier
+ object nullary // fail
+ ^
+t5429.scala:23: error: overriding method emptyArg in class A of type ()Int;
+ object emptyArg needs `override' modifier
+ object emptyArg // fail
+ ^
+t5429.scala:27: error: overriding value value in class A0 of type Any;
+ object value needs `override' modifier
+ object value // fail
+ ^
+t5429.scala:28: error: overriding lazy value lazyvalue in class A0 of type Any;
+ object lazyvalue needs `override' modifier
+ object lazyvalue // fail
+ ^
+t5429.scala:29: error: overriding method nullary in class A0 of type => Any;
+ object nullary needs `override' modifier
+ object nullary // fail
+ ^
+t5429.scala:30: error: overriding method emptyArg in class A0 of type ()Any;
+ object emptyArg needs `override' modifier
+ object emptyArg // fail
+ ^
+t5429.scala:35: error: overriding value value in class A of type Int;
+ object value has incompatible type
+ override object value // fail
+ ^
+t5429.scala:36: error: overriding lazy value lazyvalue in class A of type Int;
+ object lazyvalue must be declared lazy to override a concrete lazy value
+ override object lazyvalue // fail
+ ^
+t5429.scala:37: error: overriding method nullary in class A of type => Int;
+ object nullary has incompatible type
+ override object nullary // fail
+ ^
+t5429.scala:38: error: overriding method emptyArg in class A of type ()Int;
+ object emptyArg has incompatible type
+ override object emptyArg // fail
+ ^
+t5429.scala:39: error: object oneArg overrides nothing
+ override object oneArg // fail
+ ^
+t5429.scala:43: error: overriding lazy value lazyvalue in class A0 of type Any;
+ object lazyvalue must be declared lazy to override a concrete lazy value
+ override object lazyvalue // !!! this fails, but should succeed (lazy over lazy)
+ ^
+t5429.scala:46: error: object oneArg overrides nothing
+ override object oneArg // fail
+ ^
+t5429.scala:50: error: overriding value value in class A of type Int;
+ value value needs `override' modifier
+ val value = 0 // fail
+ ^
+t5429.scala:51: error: overriding lazy value lazyvalue in class A of type Int;
+ value lazyvalue needs `override' modifier
+ val lazyvalue = 0 // fail
+ ^
+t5429.scala:52: error: overriding method nullary in class A of type => Int;
+ value nullary needs `override' modifier
+ val nullary = 5 // fail
+ ^
+t5429.scala:53: error: overriding method emptyArg in class A of type ()Int;
+ value emptyArg needs `override' modifier
+ val emptyArg = 10 // fail
+ ^
+t5429.scala:58: error: overriding lazy value lazyvalue in class A0 of type Any;
+ value lazyvalue must be declared lazy to override a concrete lazy value
+ override val lazyvalue = 0 // fail (non-lazy)
+ ^
+t5429.scala:61: error: value oneArg overrides nothing
+ override val oneArg = 15 // fail
+ ^
+t5429.scala:65: error: overriding value value in class A of type Int;
+ method value needs `override' modifier
+ def value = 0 // fail
+ ^
+t5429.scala:66: error: overriding lazy value lazyvalue in class A of type Int;
+ method lazyvalue needs `override' modifier
+ def lazyvalue = 2 // fail
+ ^
+t5429.scala:67: error: overriding method nullary in class A of type => Int;
+ method nullary needs `override' modifier
+ def nullary = 5 // fail
+ ^
+t5429.scala:68: error: overriding method emptyArg in class A of type ()Int;
+ method emptyArg needs `override' modifier
+ def emptyArg = 10 // fail
+ ^
+t5429.scala:72: error: overriding value value in class A0 of type Any;
+ method value needs to be a stable, immutable value
+ override def value = 0 // fail
+ ^
+t5429.scala:73: error: overriding lazy value lazyvalue in class A0 of type Any;
+ method lazyvalue needs to be a stable, immutable value
+ override def lazyvalue = 2 // fail
+ ^
+t5429.scala:76: error: method oneArg overrides nothing
+ override def oneArg = 15 // fail
+ ^
+t5429.scala:80: error: overriding value value in class A of type Int;
+ lazy value value needs `override' modifier
+ lazy val value = 0 // fail
+ ^
+t5429.scala:81: error: overriding lazy value lazyvalue in class A of type Int;
+ lazy value lazyvalue needs `override' modifier
+ lazy val lazyvalue = 2 // fail
+ ^
+t5429.scala:82: error: overriding method nullary in class A of type => Int;
+ lazy value nullary needs `override' modifier
+ lazy val nullary = 5 // fail
+ ^
+t5429.scala:83: error: overriding method emptyArg in class A of type ()Int;
+ lazy value emptyArg needs `override' modifier
+ lazy val emptyArg = 10 // fail
+ ^
+t5429.scala:87: error: overriding value value in class A0 of type Any;
+ lazy value value cannot override a concrete non-lazy value
+ override lazy val value = 0 // fail (strict over lazy)
+ ^
+t5429.scala:91: error: value oneArg overrides nothing
+ override lazy val oneArg = 15 // fail
+ ^
+34 errors found
diff --git a/test/files/neg/t5429.scala b/test/files/neg/t5429.scala
new file mode 100644
index 0000000000..1cd4dcd032
--- /dev/null
+++ b/test/files/neg/t5429.scala
@@ -0,0 +1,93 @@
+// /scala/trac/5429/a.scala
+// Wed Feb 1 08:05:27 PST 2012
+
+class A {
+ val value = 0
+ lazy val lazyvalue = 2
+ def nullary = 5
+ def emptyArg() = 10
+ def oneArg(x: String) = 15
+}
+class A0 {
+ val value: Any = 0
+ lazy val lazyvalue: Any = 2
+ def nullary: Any = 5
+ def emptyArg(): Any = 10
+ def oneArg(x: String): Any = 15
+}
+
+class B extends A {
+ object value // fail
+ object lazyvalue // fail
+ object nullary // fail
+ object emptyArg // fail
+ object oneArg // overload
+}
+class B0 extends A0 {
+ object value // fail
+ object lazyvalue // fail
+ object nullary // fail
+ object emptyArg // fail
+ object oneArg // overload
+}
+
+class C extends A {
+ override object value // fail
+ override object lazyvalue // fail
+ override object nullary // fail
+ override object emptyArg // fail
+ override object oneArg // fail
+}
+class C0 extends A0 {
+ override object value // !!! this succeeds, but should fail (lazy over strict)
+ override object lazyvalue // !!! this fails, but should succeed (lazy over lazy)
+ override object nullary // override
+ override object emptyArg // override
+ override object oneArg // fail
+}
+
+class D extends A {
+ val value = 0 // fail
+ val lazyvalue = 0 // fail
+ val nullary = 5 // fail
+ val emptyArg = 10 // fail
+ val oneArg = 15 // overload
+}
+class D0 extends A0 {
+ override val value = 0 // override
+ override val lazyvalue = 0 // fail (non-lazy)
+ override val nullary = 5 // override
+ override val emptyArg = 10 // override
+ override val oneArg = 15 // fail
+}
+
+class E extends A {
+ def value = 0 // fail
+ def lazyvalue = 2 // fail
+ def nullary = 5 // fail
+ def emptyArg = 10 // fail
+ def oneArg = 15 // overload
+}
+class E0 extends A0 {
+ override def value = 0 // fail
+ override def lazyvalue = 2 // fail
+ override def nullary = 5 // override
+ override def emptyArg = 10 // override
+ override def oneArg = 15 // fail
+}
+
+class F extends A {
+ lazy val value = 0 // fail
+ lazy val lazyvalue = 2 // fail
+ lazy val nullary = 5 // fail
+ lazy val emptyArg = 10 // fail
+ lazy val oneArg = 15 // overload
+}
+class F0 extends A0 {
+ override lazy val value = 0 // fail (strict over lazy)
+ override lazy val lazyvalue = 2 // override (lazy over lazy)
+ override lazy val nullary = 5 // override
+ override lazy val emptyArg = 10 // override
+ override lazy val oneArg = 15 // fail
+}
+
diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala
index 7bdcd072b2..5b6af67a74 100644
--- a/test/files/pos/spec-Function1.scala
+++ b/test/files/pos/spec-Function1.scala
@@ -8,7 +8,7 @@
// generated by genprod on Wed Apr 23 10:06:16 CEST 2008 (with fancy comment) (with extra methods)
-package scala
+package scalabip
/** <p>
diff --git a/test/files/pos/spec-groups.scala b/test/files/pos/spec-groups.scala
new file mode 100644
index 0000000000..9b6359a982
--- /dev/null
+++ b/test/files/pos/spec-groups.scala
@@ -0,0 +1,65 @@
+import Specializable._
+
+class A[@specialized(Primitives) T](x: T) {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class B[@specialized(Everything) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class C[@specialized(Bits32AndUp) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class D[@specialized(Integral) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class E[@specialized(AllNumeric) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class F[@specialized(BestOfBreed) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class G[@specialized(Byte, Double, AnyRef) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
diff --git a/test/files/pos/specialize10.scala b/test/files/pos/specialize10.scala
new file mode 100644
index 0000000000..bbe197cda2
--- /dev/null
+++ b/test/files/pos/specialize10.scala
@@ -0,0 +1,7 @@
+trait Bippy[@specialized(
+ scala.Char, scala.Boolean, scala.Byte,
+ scala.Short, scala.Int, scala.Long,
+ scala.Float, scala.Double, scala.Unit,
+ scala.AnyRef) T] { }
+
+trait Bippy2[@specialized(Char, Boolean, Byte, Short, Int, Long, Float, Double, Unit, AnyRef) T] { }
diff --git a/test/files/run/ctries/concmap.scala b/test/files/run/ctries/concmap.scala
index 85a305ce5b..d73e33182a 100644
--- a/test/files/run/ctries/concmap.scala
+++ b/test/files/run/ctries/concmap.scala
@@ -164,6 +164,25 @@ object ConcurrentMapSpec extends Spec {
for (i <- 0 until sz) assertEqual(ct.get(new Wrap(i)), None)
}
+ "compute size correctly" in {
+ val ct = new Ctrie[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 Ctrie[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/iterator.scala b/test/files/run/ctries/iterator.scala
index 4bbf9009f0..85a6ab7623 100644
--- a/test/files/run/ctries/iterator.scala
+++ b/test/files/run/ctries/iterator.scala
@@ -274,6 +274,16 @@ object IteratorSpec extends Spec {
while (it.hasNext) it.next()
}
+ "be duplicated" in {
+ val sz = 50
+ val ct = collection.parallel.mutable.ParCtrie((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/interpolationMultiline1.check b/test/files/run/interpolationMultiline1.check
new file mode 100644
index 0000000000..09579a800a
--- /dev/null
+++ b/test/files/run/interpolationMultiline1.check
@@ -0,0 +1,26 @@
+Bob is 1 years old
+Bob is 1 years old
+Bob will be 2 years old
+Bob will be 2 years old
+1+1 = 2
+1+1 = 2
+Bob is 12 years old
+Bob is 12 years old
+Bob will be 13 years old
+Bob will be 13 years old
+12+1 = 13
+12+1 = 13
+Bob is 123 years old
+Bob is 123 years old
+Bob will be 124 years old
+Bob will be 124 years old
+123+1 = 124
+123+1 = 124
+Best price: 10.0
+Best price: 10.00
+10.0% discount included
+10.00% discount included
+Best price: 13.345
+Best price: 13.35
+13.345% discount included
+13.35% discount included
diff --git a/test/files/run/interpolationMultiline1.flags b/test/files/run/interpolationMultiline1.flags
new file mode 100644
index 0000000000..48fd867160
--- /dev/null
+++ b/test/files/run/interpolationMultiline1.flags
@@ -0,0 +1 @@
+-Xexperimental
diff --git a/test/files/run/interpolationMultiline1.scala b/test/files/run/interpolationMultiline1.scala
new file mode 100644
index 0000000000..437aed44b0
--- /dev/null
+++ b/test/files/run/interpolationMultiline1.scala
@@ -0,0 +1,26 @@
+object Test extends App {
+
+ def test1(n: Int) = {
+ println(s"""Bob is $n years old""")
+ println(f"""Bob is $n%2d years old""")
+ println(s"""Bob will be ${n+1} years old""")
+ println(f"""Bob will be ${n+1}%2d years old""")
+ println(s"""$n+1 = ${n+1}""")
+ println(f"""$n%d+1 = ${n+1}%d""")
+ }
+
+ def test2(f: Float) = {
+ println(s"""Best price: $f""")
+ println(f"""Best price: $f%.2f""")
+ println(s"""$f% discount included""")
+ println(f"""$f%3.2f% discount included""")
+ }
+
+ test1(1)
+ test1(12)
+ test1(123)
+
+ test2(10.0f)
+ test2(13.345f)
+
+}
diff --git a/test/files/run/interpolationMultiline2.check b/test/files/run/interpolationMultiline2.check
new file mode 100644
index 0000000000..7584aee9f7
--- /dev/null
+++ b/test/files/run/interpolationMultiline2.check
@@ -0,0 +1,26 @@
+Bob is 1 years old!
+java.lang.StringIndexOutOfBoundsException: String index out of range: 0
+Bob is 1 years old!
+java.lang.StringIndexOutOfBoundsException: String index out of range: 0
+Bob is 1 years old!
+Bob is 1%2d years old!
+Bob is 1 years old!
+Bob is 1%2d years old!
+===============
+Bob is 12 years old!
+java.lang.StringIndexOutOfBoundsException: String index out of range: 0
+Bob is 12 years old!
+java.lang.StringIndexOutOfBoundsException: String index out of range: 0
+Bob is 12 years old!
+Bob is 12%2d years old!
+Bob is 12 years old!
+Bob is 12%2d years old!
+===============
+Bob is 123 years old!
+java.lang.StringIndexOutOfBoundsException: String index out of range: 0
+Bob is 123 years old!
+java.lang.StringIndexOutOfBoundsException: String index out of range: 0
+Bob is 123 years old!
+Bob is 123%2d years old!
+Bob is 123 years old!
+Bob is 123%2d years old! \ No newline at end of file
diff --git a/test/files/run/interpolationMultiline2.flags b/test/files/run/interpolationMultiline2.flags
new file mode 100644
index 0000000000..e1b37447c9
--- /dev/null
+++ b/test/files/run/interpolationMultiline2.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/test/files/run/interpolationMultiline2.scala b/test/files/run/interpolationMultiline2.scala
new file mode 100644
index 0000000000..f6a682c3ce
--- /dev/null
+++ b/test/files/run/interpolationMultiline2.scala
@@ -0,0 +1,21 @@
+object Test extends App {
+
+ def test1(n: Int) = {
+ val old = "old"
+ try { println(s"""Bob is ${s"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(s"""Bob is ${f"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(f"""Bob is ${s"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(f"""Bob is ${f"$n"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(f"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(f"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(s"""Bob is ${f"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ try { println(s"""Bob is ${s"$n%2d"} years ${s"$old"}!""") } catch { case ex => println(ex) }
+ }
+
+ test1(1)
+ println("===============")
+ test1(12)
+ println("===============")
+ test1(123)
+
+}
diff --git a/test/files/run/t3575.check b/test/files/run/t3575.check
new file mode 100644
index 0000000000..c240b3d90c
--- /dev/null
+++ b/test/files/run/t3575.check
@@ -0,0 +1,4 @@
+Two
+Two
+Two
+Two$mcII$sp
diff --git a/test/files/run/t3575.scala b/test/files/run/t3575.scala
new file mode 100644
index 0000000000..56950e62bb
--- /dev/null
+++ b/test/files/run/t3575.scala
@@ -0,0 +1,12 @@
+case class Two[@specialized A, @specialized B](v: A, w: B);
+
+// This is here to tell me if the behavior changes, not because
+// the output is endorsed.
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(Two("Hello", 12).getClass().getName())
+ println(Two(12, "Hello").getClass().getName())
+ println(Two("Hello", "World").getClass().getName())
+ println(Two(12, 12).getClass().getName())
+ }
+}
diff --git a/test/files/run/t4770.check b/test/files/run/t4770.check
new file mode 100644
index 0000000000..38e5a831fa
--- /dev/null
+++ b/test/files/run/t4770.check
@@ -0,0 +1,2 @@
+(a,2)
+(2,a)
diff --git a/test/files/run/t4770.scala b/test/files/run/t4770.scala
new file mode 100644
index 0000000000..25bf3050c3
--- /dev/null
+++ b/test/files/run/t4770.scala
@@ -0,0 +1,15 @@
+package crasher {
+ class Z[@specialized A, @specialized(AnyRef) B](var a: A, var b: B) {
+ override def toString = "" + ((a, b))
+ }
+ object O {
+ def apply[@specialized A, @specialized(AnyRef) B](a0: A, b0: B) = new Z(a0, b0)
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(crasher.O("a", 2))
+ println(crasher.O(2, "a"))
+ }
+}
diff --git a/test/files/run/t4794.check b/test/files/run/t4794.check
index f599e28b8a..b4de394767 100644
--- a/test/files/run/t4794.check
+++ b/test/files/run/t4794.check
@@ -1 +1 @@
-10
+11
diff --git a/test/files/specialized/arrays-traits.check b/test/files/specialized/arrays-traits.check
index 92af4f13e1..40687a757e 100644
--- a/test/files/specialized/arrays-traits.check
+++ b/test/files/specialized/arrays-traits.check
@@ -1,6 +1,6 @@
-0
-0
-0
1
2
-1 \ No newline at end of file
+1
+3
+4
+2
diff --git a/test/files/specialized/arrays-traits.scala b/test/files/specialized/arrays-traits.scala
index de54d22d18..34a1c37a01 100644
--- a/test/files/specialized/arrays-traits.scala
+++ b/test/files/specialized/arrays-traits.scala
@@ -1,20 +1,12 @@
-
-
-
import runtime.ScalaRunTime._
-
-
trait SuperS[@specialized(AnyRef) T] {
def arr: Array[T]
def foo() = arr(0)
def bar(b: Array[T]) = b(0) = arr(0)
}
-
-class BaseS[@specialized(AnyRef) T](val arr: Array[T]) extends SuperS[T] {
-}
-
+class BaseS[@specialized(AnyRef) T](val arr: Array[T]) extends SuperS[T] { }
trait SuperG[T] {
def arr: Array[T]
@@ -22,13 +14,9 @@ trait SuperG[T] {
def bar(b: Array[T]) = b(0) = arr(0)
}
-
-class BaseG[T](val arr: Array[T]) extends SuperG[T] {
-}
-
+class BaseG[T](val arr: Array[T]) extends SuperG[T] { }
object Test {
-
def main(args: Array[String]) {
(new BaseS(new Array[String](1)): SuperS[String]).foo
println(arrayApplyCount)
@@ -42,5 +30,4 @@ object Test {
println(arrayApplyCount)
println(arrayUpdateCount)
}
-
}
diff --git a/test/files/specialized/arrays.check b/test/files/specialized/arrays.check
index d37dfb720d..8df790f413 100644
--- a/test/files/specialized/arrays.check
+++ b/test/files/specialized/arrays.check
@@ -1,4 +1,4 @@
-0
-0
50
-51 \ No newline at end of file
+51
+101
+102
diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1
index 68114c2393..27c1e8fc24 100644
--- a/test/files/speclib/instrumented.jar.desired.sha1
+++ b/test/files/speclib/instrumented.jar.desired.sha1
@@ -1 +1 @@
-2546f965f6718b000c4e6ef73559c11084177bd8 ?instrumented.jar
+23b6a7aa89b0a8a210ae9b206dfd0998338798c7 ?instrumented.jar
diff --git a/test/instrumented/boxes.patch b/test/instrumented/boxes.patch
new file mode 100644
index 0000000000..11c5b37aa8
--- /dev/null
+++ b/test/instrumented/boxes.patch
@@ -0,0 +1,29 @@
+9a10,11
+> /* INSTRUMENTED VERSION */
+>
+50a53,61
+> public static int booleanBoxCount = 0;
+> public static int characterBoxCount = 0;
+> public static int byteBoxCount = 0;
+> public static int shortBoxCount = 0;
+> public static int integerBoxCount = 0;
+> public static int longBoxCount = 0;
+> public static int floatBoxCount = 0;
+> public static int doubleBoxCount = 0;
+>
+51a63
+> booleanBoxCount++;
+55a68
+> characterBoxCount++;
+59a73
+> byteBoxCount++;
+63a78
+> shortBoxCount++;
+67a83
+> integerBoxCount++;
+71a88
+> longBoxCount++;
+75a93
+> floatBoxCount++;
+79a98
+> doubleBoxCount++;
diff --git a/test/instrumented/library/scala/runtime/BoxesRunTime.java b/test/instrumented/library/scala/runtime/BoxesRunTime.java
index 797e9f89dd..f06f86f2f2 100644
--- a/test/instrumented/library/scala/runtime/BoxesRunTime.java
+++ b/test/instrumented/library/scala/runtime/BoxesRunTime.java
@@ -30,9 +30,9 @@ import scala.math.ScalaNumber;
* @contributor Stepan Koltsov
* @version 2.0 */
public final class BoxesRunTime
-{
+{
private static final int CHAR = 0, BYTE = 1, SHORT = 2, INT = 3, LONG = 4, FLOAT = 5, DOUBLE = 6, OTHER = 7;
-
+
private static int typeCode(Object a) {
if (a instanceof java.lang.Integer) return INT;
if (a instanceof java.lang.Byte) return BYTE;
@@ -43,13 +43,13 @@ public final class BoxesRunTime
if (a instanceof java.lang.Float) return FLOAT;
return OTHER;
}
-
+
private static String boxDescription(Object a) {
return "" + a.getClass().getSimpleName() + "(" + a + ")";
}
-
+
/* BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING ... BOXING */
-
+
public static int booleanBoxCount = 0;
public static int characterBoxCount = 0;
public static int byteBoxCount = 0;
@@ -63,58 +63,58 @@ public final class BoxesRunTime
booleanBoxCount++;
return java.lang.Boolean.valueOf(b);
}
-
+
public static java.lang.Character boxToCharacter(char c) {
characterBoxCount++;
return java.lang.Character.valueOf(c);
}
-
+
public static java.lang.Byte boxToByte(byte b) {
byteBoxCount++;
return java.lang.Byte.valueOf(b);
}
-
+
public static java.lang.Short boxToShort(short s) {
shortBoxCount++;
return java.lang.Short.valueOf(s);
}
-
+
public static java.lang.Integer boxToInteger(int i) {
integerBoxCount++;
return java.lang.Integer.valueOf(i);
}
-
+
public static java.lang.Long boxToLong(long l) {
longBoxCount++;
return java.lang.Long.valueOf(l);
}
-
+
public static java.lang.Float boxToFloat(float f) {
floatBoxCount++;
return java.lang.Float.valueOf(f);
}
-
+
public static java.lang.Double boxToDouble(double d) {
doubleBoxCount++;
// System.out.println("box " + d);
// (new Throwable()).printStackTrace();
return java.lang.Double.valueOf(d);
}
-
+
/* UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING ... UNBOXING */
-
+
public static boolean unboxToBoolean(Object b) {
return b == null ? false : ((java.lang.Boolean)b).booleanValue();
}
-
+
public static char unboxToChar(Object c) {
return c == null ? 0 : ((java.lang.Character)c).charValue();
}
-
+
public static byte unboxToByte(Object b) {
return b == null ? 0 : ((java.lang.Byte)b).byteValue();
}
-
+
public static short unboxToShort(Object s) {
return s == null ? 0 : ((java.lang.Short)s).shortValue();
}
@@ -122,22 +122,22 @@ public final class BoxesRunTime
public static int unboxToInt(Object i) {
return i == null ? 0 : ((java.lang.Integer)i).intValue();
}
-
+
public static long unboxToLong(Object l) {
return l == null ? 0 : ((java.lang.Long)l).longValue();
}
-
+
public static float unboxToFloat(Object f) {
return f == null ? 0.0f : ((java.lang.Float)f).floatValue();
}
-
+
public static double unboxToDouble(Object d) {
// System.out.println("unbox " + d);
return d == null ? 0.0d : ((java.lang.Double)d).doubleValue();
}
/* COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON ... COMPARISON */
-
+
private static int eqTypeCode(Number a) {
if ((a instanceof java.lang.Integer) || (a instanceof java.lang.Byte)) return INT;
if (a instanceof java.lang.Long) return LONG;
@@ -146,8 +146,8 @@ public final class BoxesRunTime
if (a instanceof java.lang.Float) return FLOAT;
return OTHER;
}
-
- public static boolean equals(Object x, Object y) {
+
+ public static boolean equals(Object x, Object y) {
if (x == y) return true;
return equals2(x, y);
}
@@ -162,10 +162,10 @@ public final class BoxesRunTime
return equalsCharObject((java.lang.Character)x, y);
if (x == null)
return y == null;
-
+
return x.equals(y);
}
-
+
public static boolean equalsNumObject(java.lang.Number xn, Object y) {
if (y instanceof java.lang.Number)
return equalsNumNum(xn, (java.lang.Number)y);
@@ -173,10 +173,10 @@ public final class BoxesRunTime
return equalsNumChar(xn, (java.lang.Character)y);
if (xn == null)
return y == null;
-
+
return xn.equals(y);
}
-
+
public static boolean equalsNumNum(java.lang.Number xn, java.lang.Number yn) {
int xcode = eqTypeCode(xn);
int ycode = eqTypeCode(yn);
@@ -195,10 +195,10 @@ public final class BoxesRunTime
}
if (xn == null)
return yn == null;
-
+
return xn.equals(yn);
}
-
+
public static boolean equalsCharObject(java.lang.Character xc, Object y) {
if (y instanceof java.lang.Character)
return xc.charValue() == ((java.lang.Character)y).charValue();
@@ -206,7 +206,7 @@ public final class BoxesRunTime
return equalsNumChar((java.lang.Number)y, xc);
if (xc == null)
return y == null;
-
+
return xc.equals(y);
}
@@ -224,11 +224,11 @@ public final class BoxesRunTime
default:
if (xn == null)
return yc == null;
-
+
return xn.equals(yc);
}
}
-
+
/** Hashcode algorithm is driven by the requirements imposed
* by primitive equality semantics, namely that equal objects
* have equal hashCodes. The first priority are the integral/char
@@ -262,16 +262,16 @@ public final class BoxesRunTime
else return n.hashCode();
}
public static int hashFromDouble(java.lang.Double n) {
- int iv = n.intValue();
+ int iv = n.intValue();
double dv = n.doubleValue();
if (iv == dv) return iv;
-
+
long lv = n.longValue();
if (lv == dv) return java.lang.Long.valueOf(lv).hashCode();
else return n.hashCode();
}
public static int hashFromFloat(java.lang.Float n) {
- int iv = n.intValue();
+ int iv = n.intValue();
float fv = n.floatValue();
if (iv == fv) return iv;
@@ -289,9 +289,9 @@ public final class BoxesRunTime
if (a instanceof Number) return hashFromNumber((Number)a);
else return a.hashCode();
}
-
+
/* OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS ... OPERATORS */
-
+
/** arg1 + arg2 */
public static Object add(Object arg1, Object arg2) throws NoSuchMethodException {
int code1 = typeCode(arg1);
@@ -518,7 +518,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
/** -arg */
public static Object negate(Object arg) throws NoSuchMethodException {
int code = typeCode(arg);
@@ -540,7 +540,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
/** +arg */
public static Object positive(Object arg) throws NoSuchMethodException {
int code = typeCode(arg);
@@ -650,7 +650,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
/** ~arg */
public static Object complement(Object arg) throws NoSuchMethodException {
int code = typeCode(arg);
@@ -664,7 +664,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
/** !arg */
public static Object takeNot(Object arg) throws NoSuchMethodException {
if (arg instanceof Boolean) {
@@ -672,15 +672,15 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
public static Object testEqual(Object arg1, Object arg2) throws NoSuchMethodException {
return boxToBoolean(arg1 == arg2);
}
-
+
public static Object testNotEqual(Object arg1, Object arg2) throws NoSuchMethodException {
return boxToBoolean(arg1 != arg2);
}
-
+
public static Object testLessThan(Object arg1, Object arg2) throws NoSuchMethodException {
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
@@ -707,7 +707,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
public static Object testLessOrEqualThan(Object arg1, Object arg2) throws NoSuchMethodException {
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
@@ -734,7 +734,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
public static Object testGreaterOrEqualThan(Object arg1, Object arg2) throws NoSuchMethodException {
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
@@ -761,7 +761,7 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
public static Object testGreaterThan(Object arg1, Object arg2) throws NoSuchMethodException {
int code1 = typeCode(arg1);
int code2 = typeCode(arg2);
@@ -788,7 +788,25 @@ public final class BoxesRunTime
}
throw new NoSuchMethodException();
}
-
+
+ public static boolean isBoxedNumberOrBoolean(Object arg) {
+ if (arg instanceof java.lang.Boolean)
+ return true;
+ else
+ return isBoxedNumber(arg);
+ }
+ public static boolean isBoxedNumber(Object arg) {
+ return (
+ (arg instanceof java.lang.Integer)
+ || (arg instanceof java.lang.Long)
+ || (arg instanceof java.lang.Double)
+ || (arg instanceof java.lang.Float)
+ || (arg instanceof java.lang.Short)
+ || (arg instanceof java.lang.Character)
+ || (arg instanceof java.lang.Byte)
+ );
+ }
+
/** arg.toChar */
public static java.lang.Character toCharacter(Object arg) throws NoSuchMethodException {
if (arg instanceof java.lang.Integer) return boxToCharacter((char)unboxToInt(arg));
@@ -872,5 +890,5 @@ public final class BoxesRunTime
if (arg instanceof java.lang.Short) return boxToDouble((double)unboxToShort(arg));
throw new NoSuchMethodException();
}
-
+
}
diff --git a/test/instrumented/library/scala/runtime/ScalaRunTime.scala b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
index a8a74dd8ab..9eb93a418d 100644
--- a/test/instrumented/library/scala/runtime/ScalaRunTime.scala
+++ b/test/instrumented/library/scala/runtime/ScalaRunTime.scala
@@ -6,70 +6,102 @@
** |/ **
\* */
-
+package scala.runtime
/* INSTRUMENTED VERSION */
-package scala.runtime
-
-import scala.reflect.ClassManifest
-import scala.collection.{ Seq, IndexedSeq, TraversableView }
+import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator }
import scala.collection.mutable.WrappedArray
-import scala.collection.immutable.{ NumericRange, List, Stream, Nil, :: }
+import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: }
import scala.collection.generic.{ Sorted }
-import scala.xml.{ Node, MetaData }
import scala.util.control.ControlThrowable
+import scala.xml.{ Node, MetaData }
+
+import java.lang.Double.doubleToLongBits
import java.lang.reflect.{ Modifier, Method => JMethod }
-/* The object <code>ScalaRunTime</code> provides ...
+/** The object ScalaRunTime provides support methods required by
+ * the scala runtime. All these methods should be considered
+ * outside the API and subject to change or removal without notice.
*/
object ScalaRunTime {
def isArray(x: AnyRef): Boolean = isArray(x, 1)
- def isArray(x: Any, atLevel: Int): Boolean =
- x != null && isArrayClass(x.asInstanceOf[AnyRef].getClass, atLevel)
+ def isArray(x: Any, atLevel: Int): Boolean =
+ x != null && isArrayClass(x.getClass, atLevel)
private def isArrayClass(clazz: Class[_], atLevel: Int): Boolean =
clazz.isArray && (atLevel == 1 || isArrayClass(clazz.getComponentType, atLevel - 1))
- def isValueClass(clazz: Class[_]) = clazz.isPrimitive()
-
+ def isValueClass(clazz: Class[_]) = clazz.isPrimitive()
var arrayApplyCount = 0
var arrayUpdateCount = 0
-
+
+ def isTuple(x: Any) = tupleNames(x.getClass.getName)
+ def isAnyVal(x: Any) = x match {
+ case _: Byte | _: Short | _: Char | _: Int | _: Long | _: Float | _: Double | _: Boolean | _: Unit => true
+ case _ => false
+ }
+ // Avoiding boxing which messes up the specialized tests. Don't ask.
+ private val tupleNames = {
+ var i = 22
+ var names: List[String] = Nil
+ while (i >= 1) {
+ names ::= ("scala.Tuple" + String.valueOf(i))
+ i -= 1
+ }
+ names.toSet
+ }
+
+ /** Return the class object representing an unboxed value type,
+ * e.g. classOf[int], not classOf[java.lang.Integer]. The compiler
+ * rewrites expressions like 5.getClass to come here.
+ */
+ def anyValClass[T <: AnyVal](value: T): Class[T] = (value match {
+ case x: Byte => java.lang.Byte.TYPE
+ case x: Short => java.lang.Short.TYPE
+ case x: Char => java.lang.Character.TYPE
+ case x: Int => java.lang.Integer.TYPE
+ case x: Long => java.lang.Long.TYPE
+ case x: Float => java.lang.Float.TYPE
+ case x: Double => java.lang.Double.TYPE
+ case x: Boolean => java.lang.Boolean.TYPE
+ case x: Unit => java.lang.Void.TYPE
+ }).asInstanceOf[Class[T]]
+
/** Retrieve generic array element */
def array_apply(xs: AnyRef, idx: Int): Any = {
arrayApplyCount += 1
xs match {
- case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
- case x: Array[Int] => x(idx).asInstanceOf[Any]
- case x: Array[Double] => x(idx).asInstanceOf[Any]
- case x: Array[Long] => x(idx).asInstanceOf[Any]
- case x: Array[Float] => x(idx).asInstanceOf[Any]
- case x: Array[Char] => x(idx).asInstanceOf[Any]
- case x: Array[Byte] => x(idx).asInstanceOf[Any]
- case x: Array[Short] => x(idx).asInstanceOf[Any]
- case x: Array[Boolean] => x(idx).asInstanceOf[Any]
- case x: Array[Unit] => x(idx).asInstanceOf[Any]
- case null => throw new NullPointerException
- }
+ case x: Array[AnyRef] => x(idx).asInstanceOf[Any]
+ case x: Array[Int] => x(idx).asInstanceOf[Any]
+ case x: Array[Double] => x(idx).asInstanceOf[Any]
+ case x: Array[Long] => x(idx).asInstanceOf[Any]
+ case x: Array[Float] => x(idx).asInstanceOf[Any]
+ case x: Array[Char] => x(idx).asInstanceOf[Any]
+ case x: Array[Byte] => x(idx).asInstanceOf[Any]
+ case x: Array[Short] => x(idx).asInstanceOf[Any]
+ case x: Array[Boolean] => x(idx).asInstanceOf[Any]
+ case x: Array[Unit] => x(idx).asInstanceOf[Any]
+ case null => throw new NullPointerException
+ }
}
/** update generic array element */
def array_update(xs: AnyRef, idx: Int, value: Any): Unit = {
arrayUpdateCount += 1
xs match {
- case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
- case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
- case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
- case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
- case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
- case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
- case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
- case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
- case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
- case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
- case null => throw new NullPointerException
- }
+ case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef]
+ case x: Array[Int] => x(idx) = value.asInstanceOf[Int]
+ case x: Array[Double] => x(idx) = value.asInstanceOf[Double]
+ case x: Array[Long] => x(idx) = value.asInstanceOf[Long]
+ case x: Array[Float] => x(idx) = value.asInstanceOf[Float]
+ case x: Array[Char] => x(idx) = value.asInstanceOf[Char]
+ case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte]
+ case x: Array[Short] => x(idx) = value.asInstanceOf[Short]
+ case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean]
+ case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit]
+ case null => throw new NullPointerException
+ }
}
/** Get generic array length */
@@ -85,7 +117,7 @@ object ScalaRunTime {
case x: Array[Boolean] => x.length
case x: Array[Unit] => x.length
case null => throw new NullPointerException
- }
+ }
def array_clone(xs: AnyRef): AnyRef = xs match {
case x: Array[AnyRef] => ArrayRuntime.cloneArray(x)
@@ -122,7 +154,7 @@ object ScalaRunTime {
}
arr
}
-
+
// Java bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957
// More background at ticket #2318.
def ensureAccessible(m: JMethod): JMethod = {
@@ -130,10 +162,10 @@ object ScalaRunTime {
try m setAccessible true
catch { case _: SecurityException => () }
}
- m
+ m
}
- def checkInitialized[T <: AnyRef](x: T): T =
+ def checkInitialized[T <: AnyRef](x: T): T =
if (x == null) throw new UninitializedError else x
abstract class Try[+A] {
@@ -143,9 +175,9 @@ object ScalaRunTime {
def Try[A](block: => A): Try[A] = new Try[A] with Runnable {
private var result: A = _
- private var exception: Throwable =
+ private var exception: Throwable =
try { run() ; null }
- catch {
+ catch {
case e: ControlThrowable => throw e // don't catch non-local returns etc
case e: Throwable => e
}
@@ -167,27 +199,26 @@ object ScalaRunTime {
def _toString(x: Product): String =
x.productIterator.mkString(x.productPrefix + "(", ",", ")")
-
- def _hashCode(x: Product): Int = {
- import scala.util.MurmurHash._
- val arr = x.productArity
- var h = startHash(arr)
- var c = startMagicA
- var k = startMagicB
- var i = 0
- while (i < arr) {
- val elem = x.productElement(i)
- h = extendHash(h, if (elem == null) 0 else elem.##, c, k)
- c = nextMagicA(c)
- k = nextMagicB(k)
- i += 1
+
+ def _hashCode(x: Product): Int = scala.util.MurmurHash3.productHash(x)
+
+ /** A helper for case classes. */
+ def typedProductIterator[T](x: Product): Iterator[T] = {
+ new AbstractIterator[T] {
+ private var c: Int = 0
+ private val cmax = x.productArity
+ def hasNext = c < cmax
+ def next() = {
+ val result = x.productElement(c)
+ c += 1
+ result.asInstanceOf[T]
+ }
}
- finalizeHash(h)
}
/** Fast path equality method for inlining; used when -optimise is set.
*/
- @inline def inlinedEquals(x: Object, y: Object): Boolean =
+ @inline def inlinedEquals(x: Object, y: Object): Boolean =
if (x eq y) true
else if (x eq null) false
else if (x.isInstanceOf[java.lang.Number]) BoxesRunTime.equalsNumObject(x.asInstanceOf[java.lang.Number], y)
@@ -198,20 +229,21 @@ object ScalaRunTime {
case y: Product if x.productArity == y.productArity => x.productIterator sameElements y.productIterator
case _ => false
}
-
+
// hashcode -----------------------------------------------------------
//
// Note that these are the implementations called by ##, so they
// must not call ## themselves.
-
+
@inline def hash(x: Any): Int =
- if (x.isInstanceOf[java.lang.Number]) BoxesRunTime.hashFromNumber(x.asInstanceOf[java.lang.Number])
+ if (x == null) 0
+ else if (x.isInstanceOf[java.lang.Number]) BoxesRunTime.hashFromNumber(x.asInstanceOf[java.lang.Number])
else x.hashCode
-
+
@inline def hash(dv: Double): Int = {
val iv = dv.toInt
if (iv == dv) return iv
-
+
val lv = dv.toLong
if (lv == dv) return lv.hashCode
@@ -221,31 +253,27 @@ object ScalaRunTime {
@inline def hash(fv: Float): Int = {
val iv = fv.toInt
if (iv == fv) return iv
-
+
val lv = fv.toLong
- if (lv == fv) return lv.hashCode
+ if (lv == fv) return hash(lv)
else fv.hashCode
}
@inline def hash(lv: Long): Int = {
- val iv = lv.toInt
- if (iv == lv) iv else lv.hashCode
+ val low = lv.toInt
+ val lowSign = low >>> 31
+ val high = (lv >>> 32).toInt
+ low ^ (high + lowSign)
}
+ @inline def hash(x: Number): Int = runtime.BoxesRunTime.hashFromNumber(x)
+
+ // The remaining overloads are here for completeness, but the compiler
+ // inlines these definitions directly so they're not generally used.
@inline def hash(x: Int): Int = x
@inline def hash(x: Short): Int = x.toInt
@inline def hash(x: Byte): Int = x.toInt
@inline def hash(x: Char): Int = x.toInt
- @inline def hash(x: Boolean): Int = x.hashCode
+ @inline def hash(x: Boolean): Int = if (x) true.hashCode else false.hashCode
@inline def hash(x: Unit): Int = 0
-
- @inline def hash(x: Number): Int = runtime.BoxesRunTime.hashFromNumber(x)
-
- /** XXX Why is there one boxed implementation in here? It would seem
- * we should have all the numbers or none of them.
- */
- @inline def hash(x: java.lang.Long): Int = {
- val iv = x.intValue
- if (iv == x.longValue) iv else x.hashCode
- }
/** A helper method for constructing case class equality methods,
* because existential types get in the way of a clean outcome and
@@ -263,17 +291,13 @@ object ScalaRunTime {
* called on null and (b) depending on the apparent type of an
* array, toString may or may not print it in a human-readable form.
*
- * @param arg the value to stringify
- * @return a string representation of <code>arg</code>
- *
- */
+ * @param arg the value to stringify
+ * @return a string representation of arg.
+ */
def stringOf(arg: Any): String = stringOf(arg, scala.Int.MaxValue)
- def stringOf(arg: Any, maxElements: Int): String = {
+ def stringOf(arg: Any, maxElements: Int): String = {
def isScalaClass(x: AnyRef) =
Option(x.getClass.getPackage) exists (_.getName startsWith "scala.")
-
- def isTuple(x: AnyRef) =
- x.getClass.getName matches """^scala\.Tuple(\d+).*"""
// When doing our own iteration is dangerous
def useOwnToString(x: Any) = x match {
@@ -283,8 +307,8 @@ object ScalaRunTime {
case _: Range | _: NumericRange[_] => true
// Sorted collections to the wrong thing (for us) on iteration - ticket #3493
case _: Sorted[_, _] => true
- // StringBuilder(a, b, c) is not so attractive
- case _: StringBuilder => true
+ // StringBuilder(a, b, c) and similar not so attractive
+ case _: StringLike[_] => true
// Don't want to evaluate any elements in a view
case _: TraversableView[_, _] => true
// Don't want to a) traverse infinity or b) be overly helpful with peoples' custom
@@ -299,14 +323,27 @@ object ScalaRunTime {
case (k, v) => inner(k) + " -> " + inner(v)
case _ => inner(arg)
}
- // The recursively applied attempt to prettify Array printing
+
+ // Special casing Unit arrays, the value class which uses a reference array type.
+ def arrayToString(x: AnyRef) = {
+ if (x.getClass.getComponentType == classOf[BoxedUnit])
+ 0 until (array_length(x) min maxElements) map (_ => "()") mkString ("Array(", ", ", ")")
+ else
+ WrappedArray make x take maxElements map inner mkString ("Array(", ", ", ")")
+ }
+
+ // The recursively applied attempt to prettify Array printing.
+ // Note that iterator is used if possible and foreach is used as a
+ // last resort, because the parallel collections "foreach" in a
+ // random order even on sequences.
def inner(arg: Any): String = arg match {
case null => "null"
case "" => "\"\""
case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x
- case x if useOwnToString(x) => x.toString
- case x: AnyRef if isArray(x) => WrappedArray make x take maxElements map inner mkString ("Array(", ", ", ")")
- case x: collection.Map[_, _] => x take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")")
+ case x if useOwnToString(x) => x toString
+ case x: AnyRef if isArray(x) => arrayToString(x)
+ case x: collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")")
+ case x: Iterable[_] => x.iterator take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")")
case x: Traversable[_] => x take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")")
case x: Product1[_] if isTuple(x) => "(" + inner(x._1) + ",)" // that special trailing comma
case x: Product if isTuple(x) => x.productIterator map inner mkString ("(", ",", ")")
@@ -315,13 +352,31 @@ object ScalaRunTime {
// The try/catch is defense against iterables which aren't actually designed
// to be iterated, such as some scala.tools.nsc.io.AbstractFile derived classes.
- val s =
- try inner(arg)
- catch {
- case _: StackOverflowError | _: UnsupportedOperationException => arg.toString
- }
-
+ try inner(arg)
+ catch {
+ case _: StackOverflowError | _: UnsupportedOperationException | _: AssertionError => "" + arg
+ }
+ }
+
+ /** stringOf formatted for use in a repl result. */
+ def replStringOf(arg: Any, maxElements: Int): String = {
+ val s = stringOf(arg, maxElements)
val nl = if (s contains "\n") "\n" else ""
- nl + s + "\n"
+
+ nl + s + "\n"
+ }
+ private[scala] def checkZip(what: String, coll1: TraversableOnce[_], coll2: TraversableOnce[_]) {
+ if (sys.props contains "scala.debug.zip") {
+ val xs = coll1.toIndexedSeq
+ val ys = coll2.toIndexedSeq
+ if (xs.length != ys.length) {
+ Console.err.println(
+ "Mismatched zip in " + what + ":\n" +
+ " this: " + xs.mkString(", ") + "\n" +
+ " that: " + ys.mkString(", ")
+ )
+ (new Exception).getStackTrace.drop(2).take(10).foreach(println)
+ }
+ }
}
}
diff --git a/test/instrumented/mkinstrumented b/test/instrumented/mkinstrumented
deleted file mode 100755
index a87e8cb94f..0000000000
--- a/test/instrumented/mkinstrumented
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-#
-# Used to compile a jar with instrumented versions of certain classes.
-#
-
-
-
-
-if [ $# -ne 1 ]
-then
- echo "Must provide build dir ('target' or 'build')."
- exit 1
-fi
-
-
-BUILDDIR=$1
-TOPDIR=../..
-SCALAC=$TOPDIR/$BUILDDIR/pack/bin/scalac
-SRC_DIR=library/
-SCALALIB=$TOPDIR/$BUILDDIR/pack/lib/scala-library.jar
-CLASSDIR=classes/
-ARTIFACT=instrumented.jar
-
-
-# compile it
-rm -rf $CLASSDIR
-mkdir $CLASSDIR
-JSOURCES=`find $SRC_DIR -name "*.java" -print`
-SOURCES=`find $SRC_DIR \( -name "*.scala" -o -name "*.java" \) -print`
-echo $SOURCES
-$SCALAC -d $CLASSDIR $SOURCES
-javac -cp $SCALALIB -d $CLASSDIR $JSOURCES
-
-
-# jar it up
-rm $ARTIFACT
-cd $CLASSDIR
-jar cf $ARTIFACT .
-mv $ARTIFACT ../
-cd ..
-
-
-
-
-
-
diff --git a/test/instrumented/mkinstrumented.sh b/test/instrumented/mkinstrumented.sh
new file mode 100755
index 0000000000..d734dd2e00
--- /dev/null
+++ b/test/instrumented/mkinstrumented.sh
@@ -0,0 +1,51 @@
+#/bin/sh
+#
+# Used to compile a jar with instrumented versions of certain classes.
+#
+
+set -e
+
+run () {
+ echo "% $@"
+ "$@"
+}
+
+if [ $# -ne 1 ]
+then
+ echo "Must provide build dir ('target' or 'build')."
+ exit 1
+fi
+
+scriptDir=$(cd $(dirname $0) && pwd)
+
+TOPDIR="$scriptDir/../.."
+RUNTIME="$TOPDIR/src/library/scala/runtime"
+SOURCES="$RUNTIME/BoxesRunTime.java $RUNTIME/ScalaRunTime.scala"
+SCALAC=$TOPDIR/$1/pack/bin/scalac
+SRC_DIR="$scriptDir/library/scala/runtime"
+SCALALIB=$TOPDIR/$1/pack/lib/scala-library.jar
+CLASSDIR="$scriptDir/classes"
+ARTIFACT=instrumented.jar
+DESTINATION="$TOPDIR/test/files/speclib"
+
+[[ -x "$SCALAC" ]] || exit 1;
+
+# compile it
+run rm -rf $CLASSDIR && mkdir $CLASSDIR
+run cp $SOURCES $SRC_DIR
+( cd $SRC_DIR && run patch BoxesRunTime.java $scriptDir/boxes.patch && run patch ScalaRunTime.scala $scriptDir/srt.patch )
+
+ORIG=$(find $SRC_DIR -name '*.orig')
+[[ -z "$ORIG" ]] || rm -f $ORIG
+
+JSOURCES=$(find $SRC_DIR -name "*.java" -print)
+SOURCES=$(find $SRC_DIR -type f -print)
+# echo $SOURCES
+run $SCALAC -d $CLASSDIR $SOURCES
+run javac -cp $SCALALIB -d $CLASSDIR $JSOURCES
+
+# jar it up
+run cd $CLASSDIR
+run jar cf $ARTIFACT .
+run mv -f $ARTIFACT "$DESTINATION"
+echo "$(cd "$DESTINATION" && pwd)/$ARTIFACT has been created." \ No newline at end of file
diff --git a/test/instrumented/srt.patch b/test/instrumented/srt.patch
new file mode 100644
index 0000000000..2f472ff1c0
--- /dev/null
+++ b/test/instrumented/srt.patch
@@ -0,0 +1,23 @@
+9a10,11
+> /* INSTRUMENTED VERSION */
+>
+33a36,38
+> var arrayApplyCount = 0
+> var arrayUpdateCount = 0
+>
+35c40,42
+< def array_apply(xs: AnyRef, idx: Int): Any = xs match {
+---
+> def array_apply(xs: AnyRef, idx: Int): Any = {
+> arrayApplyCount += 1
+> xs match {
+47a55
+> }
+50c58,60
+< def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match {
+---
+> def array_update(xs: AnyRef, idx: Int, value: Any): Unit = {
+> arrayUpdateCount += 1
+> xs match {
+62a73
+> }
diff --git a/test/pending/pos/t4012.scala b/test/pending/pos/t4012.scala
new file mode 100644
index 0000000000..9b8a1b0dbe
--- /dev/null
+++ b/test/pending/pos/t4012.scala
@@ -0,0 +1,7 @@
+trait C1[+A] {
+ def head: A = sys.error("")
+}
+trait C2[@specialized +A] extends C1[A] {
+ override def head: A = super.head
+}
+class C3 extends C2[Char] \ No newline at end of file
diff --git a/test/pending/pos/t4541.scala b/test/pending/pos/t4541.scala
new file mode 100644
index 0000000000..c6d9672cc5
--- /dev/null
+++ b/test/pending/pos/t4541.scala
@@ -0,0 +1,10 @@
+@SerialVersionUID(1L)
+final class SparseArray[@specialized T](private var data : Array[T]) extends Serializable {
+ def use(inData : Array[T]) = {
+ data = inData;
+ }
+
+ def set(that : SparseArray[T]) = {
+ use(that.data.clone)
+ }
+} \ No newline at end of file
diff --git a/test/pending/pos/t4786.scala b/test/pending/pos/t4786.scala
new file mode 100644
index 0000000000..f0579142b8
--- /dev/null
+++ b/test/pending/pos/t4786.scala
@@ -0,0 +1,24 @@
+trait Matrix[@specialized A, Repr[C] <: Matrix[C, Repr]] { // crash goes away if @specialize is removed
+ def duplicate(mb: MatrixBuilder[A, Repr]): Repr[A] = {
+ mb.zeros
+ }
+}
+trait DenseMatrix[@specialized A] extends Matrix[A, DenseMatrix]
+trait DenseMatrixFlt extends DenseMatrix[Float]
+
+trait MatrixBuilder[@specialized A, Repr[C] <: Matrix[C, Repr]] {
+ def zeros: Repr[A]
+}
+object DenseFloatBuilder extends MatrixBuilder[Float, DenseMatrix] {
+ val zeros = new Object with DenseMatrixFlt
+ // Note:
+ // - in 2.9 crash goes away if the explicit type "DenseMatrixFlt" is assigned to "zeros"
+ // - in 2.9 crash goes away if DenseMatrixFlt is a class instead of a trait:
+ // val zeros = new DenseMatrixFlt
+}
+
+object Test extends App {
+ val m1 = DenseFloatBuilder.zeros // in 2.9 crash goes away if explicit type "DenseMatrixFlt" is assigned to m1
+ val m2 = m1.duplicate(DenseFloatBuilder)
+}
+
diff --git a/test/pending/pos/t4790.scala b/test/pending/pos/t4790.scala
new file mode 100644
index 0000000000..e451fe80ab
--- /dev/null
+++ b/test/pending/pos/t4790.scala
@@ -0,0 +1,4 @@
+package spectest {
+ class Sp[@specialized A, B](val a: A, val b: B) { }
+ class Fsp[@specialized A, B](a: A, b: B) extends Sp(a,b) { def ab = (a,b) }
+}
diff --git a/test/pending/run/t4511.scala b/test/pending/run/t4511.scala
new file mode 100644
index 0000000000..58d4e0c7b0
--- /dev/null
+++ b/test/pending/run/t4511.scala
@@ -0,0 +1,10 @@
+class Interval[@specialized T](val high: T)
+class Node[@specialized T](val interval: Interval[T]) {
+ val x1 = Some(interval.high)
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ new Node(new Interval(5)).x1
+ }
+} \ No newline at end of file
diff --git a/test/pending/run/t4971.scala b/test/pending/run/t4971.scala
new file mode 100644
index 0000000000..c9b6d6f39f
--- /dev/null
+++ b/test/pending/run/t4971.scala
@@ -0,0 +1,16 @@
+trait A[@specialized(Int) K, @specialized(Double) V] {
+ def doStuff(k: K, v: V): Unit = sys.error("I am overridden, you cannot call me")
+}
+
+trait B[@specialized(Double) V] extends A[Int, V] {
+ override def doStuff(k: Int, v: V): Unit = println("Hi - I'm calling doStuff in B")
+}
+
+object Test {
+ def main(args: Array[String]): Unit = delegate(new B[Double]() {}, 1, 0.1)
+
+ def delegate[@specialized(Int) K, @specialized(Double) V](a: A[K, V], k: K, v: V) {
+ a.doStuff(k, v)
+ }
+}
+
diff --git a/test/pending/run/t5284.scala b/test/pending/run/t5284.scala
new file mode 100644
index 0000000000..b43afed5b8
--- /dev/null
+++ b/test/pending/run/t5284.scala
@@ -0,0 +1,14 @@
+object Test {
+ def main(args:Array[String]) {
+ val a = Blarg(Array(1,2,3))
+ println(a.m((x:Int) => x+1))
+ }
+}
+
+object Blarg {
+ def apply[T:Manifest](a:Array[T]) = new Blarg(a)
+}
+class Blarg [@specialized T:Manifest](val a:Array[T]) {
+ def m[@specialized W>:T,@specialized S](f:W=>S) = f(a(0))
+}
+