diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-17 09:52:40 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-17 11:10:23 -0800 |
commit | 1e648c386216d4c60121321a7ec40e2536bada9c (patch) | |
tree | 300e7095cf45ba476dd5717f028cd154f4e7f702 /test | |
parent | 91148376049a152edec12348ff9b7e9e93e6ebe1 (diff) | |
download | scala-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')
-rw-r--r-- | test/files/buildmanager/t2652/t2652.check | 2 | ||||
-rw-r--r-- | test/files/run/t4794.check | 2 | ||||
-rw-r--r-- | test/files/run/t5488-fn.check | 17 | ||||
-rw-r--r-- | test/files/run/t5488-fn.scala | 49 | ||||
-rw-r--r-- | test/files/run/t5488.check | 14 | ||||
-rw-r--r-- | test/files/run/t5488.scala | 26 | ||||
-rw-r--r-- | test/pending/run/t4770.check (renamed from test/files/run/t4770.check) | 0 | ||||
-rw-r--r-- | test/pending/run/t4770.scala (renamed from test/files/run/t4770.scala) | 0 |
8 files changed, 108 insertions, 2 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/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]()) + } +} diff --git a/test/files/run/t4770.check b/test/pending/run/t4770.check index 38e5a831fa..38e5a831fa 100644 --- a/test/files/run/t4770.check +++ b/test/pending/run/t4770.check diff --git a/test/files/run/t4770.scala b/test/pending/run/t4770.scala index 25bf3050c3..25bf3050c3 100644 --- a/test/files/run/t4770.scala +++ b/test/pending/run/t4770.scala |