diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/primitive-sigs-1.check | 6 | ||||
-rw-r--r-- | test/files/neg/primitive-sigs-1/A_1.scala | 9 | ||||
-rw-r--r-- | test/files/neg/primitive-sigs-1/A_3.scala | 5 | ||||
-rw-r--r-- | test/files/neg/primitive-sigs-1/J_2.java | 8 | ||||
-rw-r--r-- | test/files/run/primitive-sigs-2.check | 3 | ||||
-rw-r--r-- | test/files/run/primitive-sigs-2.scala | 20 |
6 files changed, 51 insertions, 0 deletions
diff --git a/test/files/neg/primitive-sigs-1.check b/test/files/neg/primitive-sigs-1.check new file mode 100644 index 0000000000..befb8219dd --- /dev/null +++ b/test/files/neg/primitive-sigs-1.check @@ -0,0 +1,6 @@ +A_3.scala:3: error: type mismatch; + found : Bippy + required: AC[java.lang.Integer] + J_2.f(new Bippy()) + ^ +one error found 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<Integer> x) { return x.f(); } + public static void main(String[] args) { + f(new Bippy()); + } +} diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2.check new file mode 100644 index 0000000000..4ecec9f199 --- /dev/null +++ b/test/files/run/primitive-sigs-2.check @@ -0,0 +1,3 @@ +T<java.lang.Object> interface scala.ScalaObject +List(A, char, class java.lang.Object) +a 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) + } +} |