summaryrefslogtreecommitdiff
path: root/test/pending/pos/t4786.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-14 22:04:30 -0800
committerPaul Phillips <paulp@improving.org>2012-02-14 23:49:28 -0800
commitbb23d766bceccecc99280b543001bc70e16afbc9 (patch)
treec6c737a25ee99b1910db06f527f0a123d89c6752 /test/pending/pos/t4786.scala
parent4c48abbe5a438b5c892ee096d816770213c54ef5 (diff)
downloadscala-bb23d766bceccecc99280b543001bc70e16afbc9.tar.gz
scala-bb23d766bceccecc99280b543001bc70e16afbc9.tar.bz2
scala-bb23d766bceccecc99280b543001bc70e16afbc9.zip
Specialization action.
The crickets at http://www.scala-lang.org/node/11901 were in unanimous agreement that I should proceed as suggested. - No arguments to @specialize gets you 10/10, not 9/10 - Fixed bugs in AnyRef specialization revealed by trying to use it - Specialized Function1 on AnyRef. - Changed AnyRef specialization to use OBJECT_TAG, not TVAR_TAG. - Deprecated SpecializableCompanion in favor of Specializable, which has the virtue of being public so it can be referenced from outside the library. - Cooked up mechanism to group specializable types so we don't have to repeat ourselves quite so much, and create a few groups for illustrative purposes. I'm not too serious about those names but I used up all my name-thinking-up brain for the day. - Updated genprod and friends since I had to regenerate Function1. - Put tests for a bunch of remaining specialization bugs in pending. Closes SI-4740, SI-4770, SI-5267.
Diffstat (limited to 'test/pending/pos/t4786.scala')
-rw-r--r--test/pending/pos/t4786.scala24
1 files changed, 24 insertions, 0 deletions
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)
+}
+