From e42733e9fe1f3af591976fbb48b66035253d85b9 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 2 Mar 2011 02:34:54 +0000 Subject: 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 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. --- test/files/neg/primitive-sigs-1/A_1.scala | 9 +++++++++ test/files/neg/primitive-sigs-1/A_3.scala | 5 +++++ test/files/neg/primitive-sigs-1/J_2.java | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 test/files/neg/primitive-sigs-1/A_1.scala create mode 100644 test/files/neg/primitive-sigs-1/A_3.scala create mode 100644 test/files/neg/primitive-sigs-1/J_2.java (limited to 'test/files/neg/primitive-sigs-1') diff --git a/test/files/neg/primitive-sigs-1/A_1.scala b/test/files/neg/primitive-sigs-1/A_1.scala new file mode 100644 index 0000000000..0dd83b5d6a --- /dev/null +++ b/test/files/neg/primitive-sigs-1/A_1.scala @@ -0,0 +1,9 @@ +// scala: the signature in the abstract class will use the +// upper bound as return type, which for us will be Integer +// since primitives can't appear in bounds. +abstract class AC[T <: Int] { + def f(): T +} +class Bippy extends AC[Int] { + def f(): Int = 5 +} \ No newline at end of file diff --git a/test/files/neg/primitive-sigs-1/A_3.scala b/test/files/neg/primitive-sigs-1/A_3.scala new file mode 100644 index 0000000000..dec617a111 --- /dev/null +++ b/test/files/neg/primitive-sigs-1/A_3.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + J_2.f(new Bippy()) + } +} diff --git a/test/files/neg/primitive-sigs-1/J_2.java b/test/files/neg/primitive-sigs-1/J_2.java new file mode 100644 index 0000000000..b416befb4d --- /dev/null +++ b/test/files/neg/primitive-sigs-1/J_2.java @@ -0,0 +1,8 @@ +// java: often the java or scala compiler will save us from +// the untruth in the signature, but not always. +public class J_2 { + public static Integer f(AC x) { return x.f(); } + public static void main(String[] args) { + f(new Bippy()); + } +} -- cgit v1.2.3