diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/pos/spec.scala | 64 | ||||
-rw-r--r-- | test/files/specialized/arrays.check | 4 | ||||
-rw-r--r-- | test/files/specialized/arrays.scala | 55 | ||||
-rw-r--r-- | test/files/speclib/instrumented.jar.desired.sha1 | 2 |
4 files changed, 124 insertions, 1 deletions
diff --git a/test/files/pos/spec.scala b/test/files/pos/spec.scala new file mode 100644 index 0000000000..e8df1bb14a --- /dev/null +++ b/test/files/pos/spec.scala @@ -0,0 +1,64 @@ + + + + +// class Bar[@specialized(Int, AnyRef) A](a: A) { +// val memb = a +// } + + +// class WithInner[@specialized(Int, AnyRef) A](a: A) { +// class Inner { +// def meth = a +// } +// } + + +// class Baz[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B] { +// def ab(a: A, b: B) = (a, b) +// } + + +// trait Base[@specialized(Int, AnyRef) A] +// class Concrete[@specialized(Int, AnyRef) A] extends Base[A] + + +// class WithAnon[@specialized(Int, AnyRef) A](a: A) { +// new AnyRef { +// def foo = a +// } +// } + + +// class Norm { +// def id[@specialized(Int, AnyRef) A](a: A) = a +// } + + +// class Qux[@specialized(AnyRef) A] { +// def memb[@specialized(AnyRef) B](a: A, b: B) = (a, b) +// } + + +// class Foo[@specialized(Int, AnyRef) A](val a: Array[A]) { +// a(0) + +// def id(elem: A) = a(0) = elem +// } + + +// instantiation and selection +object Test { + def main(arg: Array[String]) { + // val f = new Foo(new Array[String](5)) + // f.id("") + + // val z = new Baz[Int, Double] + // z.ab(1, 1.0) + + testspec(new Array[String](5)) + testspec(new Array[Int](5)) + } + + def testspec[@specialized(Int, AnyRef) T](arr: Array[T]) = arr(0) +} diff --git a/test/files/specialized/arrays.check b/test/files/specialized/arrays.check new file mode 100644 index 0000000000..d37dfb720d --- /dev/null +++ b/test/files/specialized/arrays.check @@ -0,0 +1,4 @@ +0 +0 +50 +51
\ No newline at end of file diff --git a/test/files/specialized/arrays.scala b/test/files/specialized/arrays.scala new file mode 100644 index 0000000000..505f482486 --- /dev/null +++ b/test/files/specialized/arrays.scala @@ -0,0 +1,55 @@ + + + +import runtime.ScalaRunTime._ + + +class Generic[T](a: Array[T]) { + def apply() = a(0) +} + + +class Spec[@specialized(AnyRef) T](a: Array[T]) { + def apply() = a(0) +} + + +object Test { + + def main(args: Array[String]) { + val len = 50 + + testSpec(new Array[String](len)) + println(arrayApplyCount) + + (new Spec(new Array[String](len)))() + println(arrayApplyCount) + + testGeneric(new Array[String](len)) + println(arrayApplyCount) + + (new Generic(new Array[String](len)))() + println(arrayApplyCount) + } + + def testGeneric[T](a: Array[T]) = { + var i = 0 + var sum = 0 + while (i < a.length) { + sum += (if (a(i) != null) 1 else 0) + i += 1 + } + sum + } + + def testSpec[@specialized(AnyRef) T](a: Array[T]) = { + var i = 0 + var sum = 0 + while (i < a.length) { + sum += (if (a(i) != null) 1 else 0) + i += 1 + } + sum + } + +} diff --git a/test/files/speclib/instrumented.jar.desired.sha1 b/test/files/speclib/instrumented.jar.desired.sha1 index 159d1f0db9..bc9f3a387b 100644 --- a/test/files/speclib/instrumented.jar.desired.sha1 +++ b/test/files/speclib/instrumented.jar.desired.sha1 @@ -1 +1 @@ -c3c486551044098e473d18e2c271f92d2ca7605f ?instrumented.jar +0b7a1e1e0ee0ba8f2d3f00f3ad59eda0d2ab7eea ?instrumented.jar |