summaryrefslogtreecommitdiff
path: root/test/files/run/primitive-sigs-2.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-02 02:34:54 +0000
committerPaul Phillips <paulp@improving.org>2011-03-02 02:34:54 +0000
commite42733e9fe1f3af591976fbb48b66035253d85b9 (patch)
treef91c3aef289cb7e58347484d1375437b2230e729 /test/files/run/primitive-sigs-2.scala
parent2021f393627c8a853248a5d6178b86f3d5d7f763 (diff)
downloadscala-e42733e9fe1f3af591976fbb48b66035253d85b9.tar.gz
scala-e42733e9fe1f3af591976fbb48b66035253d85b9.tar.bz2
scala-e42733e9fe1f3af591976fbb48b66035253d85b9.zip
Another lap around the track with generic signa...
Another lap around the track with generic signatures. At the root of the issue reported in #4214 is our old friend (fondly remembered from the days of primitive equality) boxed/primitive unification. // scala trait T[A] { def f(): A } // the generic signature spec doesn't allow for parameterizing // on primitive types, so this cannot remain Char. However // translating it to Character, as was done, also has issues. class C extends T[Char] { def f(): Char = 'a' } // Note that neither of the signatures for f, the implementation // or the bridge method, matches the type parameter. Generic interfaces in class: T<java.lang.Character> Generic signatures: public char C.f() public java.lang.Object C.f() After this commit, primitive type parameters are translated into Object instead of the boxed type. It was martin's idea, so no review. Closes #4214.
Diffstat (limited to 'test/files/run/primitive-sigs-2.scala')
-rw-r--r--test/files/run/primitive-sigs-2.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/files/run/primitive-sigs-2.scala b/test/files/run/primitive-sigs-2.scala
new file mode 100644
index 0000000000..a8876f7f60
--- /dev/null
+++ b/test/files/run/primitive-sigs-2.scala
@@ -0,0 +1,20 @@
+trait T[A] {
+ def f(): A
+}
+class C extends T[Char] {
+ def f(): Char = 'a'
+}
+
+object Test {
+ val c1: Class[_] = classOf[T[_]]
+ val c2: Class[_] = classOf[C]
+
+ val c1m = c1.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString)
+ val c2m = c2.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString)
+
+ def main(args: Array[String]): Unit = {
+ println(c2.getGenericInterfaces.map(_.toString).sorted mkString " ")
+ println(c1m ++ c2m sorted)
+ println(new C f)
+ }
+}