summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-17 09:52:40 -0800
committerPaul Phillips <paulp@improving.org>2012-02-17 11:10:23 -0800
commit1e648c386216d4c60121321a7ec40e2536bada9c (patch)
tree300e7095cf45ba476dd5717f028cd154f4e7f702 /test/files
parent91148376049a152edec12348ff9b7e9e93e6ebe1 (diff)
downloadscala-1e648c386216d4c60121321a7ec40e2536bada9c.tar.gz
scala-1e648c386216d4c60121321a7ec40e2536bada9c.tar.bz2
scala-1e648c386216d4c60121321a7ec40e2536bada9c.zip
Fixed AnyRef specialization.
At least for the value of fix which means "better than it was in 2.9." I accidentally spent a long while trying to fix something I didn't realize I hadn't broken. But then I lucked into partially fixing it, so that's good news. See run/t5488-fn.scala if you want to see what still doesn't work. (It's covered at SI-4770, which is now reopened.) Closes SI-5488.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/buildmanager/t2652/t2652.check2
-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/run/t5488-fn.check17
-rw-r--r--test/files/run/t5488-fn.scala49
-rw-r--r--test/files/run/t5488.check14
-rw-r--r--test/files/run/t5488.scala26
8 files changed, 108 insertions, 19 deletions
diff --git a/test/files/buildmanager/t2652/t2652.check b/test/files/buildmanager/t2652/t2652.check
index b84c80205e..071281c6ff 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$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>]))
+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>]))
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/run/t4770.check b/test/files/run/t4770.check
deleted file mode 100644
index 38e5a831fa..0000000000
--- a/test/files/run/t4770.check
+++ /dev/null
@@ -1,2 +0,0 @@
-(a,2)
-(2,a)
diff --git a/test/files/run/t4770.scala b/test/files/run/t4770.scala
deleted file mode 100644
index 25bf3050c3..0000000000
--- a/test/files/run/t4770.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-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 b4de394767..f599e28b8a 100644
--- a/test/files/run/t4794.check
+++ b/test/files/run/t4794.check
@@ -1 +1 @@
-11
+10
diff --git a/test/files/run/t5488-fn.check b/test/files/run/t5488-fn.check
new file mode 100644
index 0000000000..196f58d063
--- /dev/null
+++ b/test/files/run/t5488-fn.check
@@ -0,0 +1,17 @@
+B$mcII$sp
+B
+B$mcIV$sp
+B$mcLI$sp
+B
+B$mcLV$sp
+B$mcVI$sp
+B
+B$mcVV$sp
+C$mcIII$sp
+C
+C$mcILI$sp
+C
+C$mcLII$sp
+C
+C$mcLLI$sp
+C
diff --git a/test/files/run/t5488-fn.scala b/test/files/run/t5488-fn.scala
new file mode 100644
index 0000000000..9e4f60002b
--- /dev/null
+++ b/test/files/run/t5488-fn.scala
@@ -0,0 +1,49 @@
+class B[@specialized(Int, AnyRef, Unit) A, @specialized(Int, Unit) B](f: A => B)
+class C[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(Int) C](f: (A, B) => C)
+// Not yet:
+// class B[@specialized(Int, AnyRef, Unit) A, @specialized(Int, AnyRef, Unit) B](f: A => B)
+// class C[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(Int, AnyRef) C](f: (A, B) => C)
+
+object Test {
+ def main(args:Array[String]) {
+ def show(x: Any) = println(x.getClass.getName)
+
+ show(new B((x: Int) => 1))
+ show(new B((x: Int) => "abc"))
+ show(new B((x: Int) => ()))
+ show(new B((x: AnyRef) => 1))
+ show(new B((x: AnyRef) => "abc"))
+ show(new B((x: AnyRef) => ()))
+ show(new B((x: Unit) => 1))
+ show(new B((x: Unit) => "abc"))
+ show(new B((x: Unit) => ()))
+
+ show(new C((x: Int, y: Int) => 1))
+ show(new C((x: Int, y: Int) => "abc"))
+ show(new C((x: Int, y: AnyRef) => 1))
+ show(new C((x: Int, y: AnyRef) => "abc"))
+ show(new C((x: AnyRef, y: Int) => 1))
+ show(new C((x: AnyRef, y: Int) => "abc"))
+ show(new C((x: AnyRef, y: AnyRef) => 1))
+ show(new C((x: AnyRef, y: AnyRef) => "abc"))
+ }
+}
+/** If the return types are specialized on AnyRef as well:
+
+files/run/t5488-fn.scala:18: error: type mismatch;
+ found : Unit => String
+ required: Unit => B$sp
+ show(new B((x: Unit) => "abc"))
+ ^
+files/run/t5488-fn.scala:24: error: type mismatch;
+ found : (Int, Object) => String
+ required: (Int, B$sp) => C$sp
+ show(new C((x: Int, y: AnyRef) => "abc"))
+ ^
+files/run/t5488-fn.scala:26: error: type mismatch;
+ found : (Object, Int) => String
+ required: (A$sp, Int) => C$sp
+ show(new C((x: AnyRef, y: Int) => "abc"))
+ ^
+three errors found
+**/
diff --git a/test/files/run/t5488.check b/test/files/run/t5488.check
new file mode 100644
index 0000000000..ccd98c4dbc
--- /dev/null
+++ b/test/files/run/t5488.check
@@ -0,0 +1,14 @@
+A0$mcI$sp
+A0
+B0$mcII$sp
+B0$mcIL$sp
+B0$mcLI$sp
+B0
+C0$mcIII$sp
+C0$mcIIL$sp
+C0$mcILI$sp
+C0$mcILL$sp
+C0$mcLII$sp
+C0$mcLIL$sp
+C0$mcLLI$sp
+C0
diff --git a/test/files/run/t5488.scala b/test/files/run/t5488.scala
new file mode 100644
index 0000000000..7bab0cdc3c
--- /dev/null
+++ b/test/files/run/t5488.scala
@@ -0,0 +1,26 @@
+class A0[@specialized(Int, AnyRef) A]()
+class B0[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B]()
+class C0[@specialized(Int, AnyRef) A, @specialized(Int, AnyRef) B, @specialized(Int, AnyRef) C]()
+
+object Test {
+ def main(args:Array[String]) {
+ def show(x: Any) = println(x.getClass.getName)
+
+ show(new A0[Int]())
+ show(new A0[AnyRef]())
+
+ show(new B0[Int, Int]())
+ show(new B0[Int, AnyRef]())
+ show(new B0[AnyRef, Int]())
+ show(new B0[AnyRef, AnyRef]())
+
+ show(new C0[Int, Int, Int]())
+ show(new C0[Int, Int, AnyRef]())
+ show(new C0[Int, AnyRef, Int]())
+ show(new C0[Int, AnyRef, AnyRef]())
+ show(new C0[AnyRef, Int, Int]())
+ show(new C0[AnyRef, Int, AnyRef]())
+ show(new C0[AnyRef, AnyRef, Int]())
+ show(new C0[AnyRef, AnyRef, AnyRef]())
+ }
+}