Permalink
Browse files

Test that primitive arrays aren't accepted as a Java generic array.

They exercise both joint and separate compilation.

This resolves SI-750 (which was somewhat unfairly merged with another ticket).

The error message itself could do with refinement: in particular instance of the much beloved: found X, required X.
  • Loading branch information...
retronym committed May 6, 2012
1 parent 7cac633 commit 5ca799d8c980ab865b03f98083dea1e089f9ae03
View
@@ -0,0 +1,15 @@
Test_2.scala:4: error: type mismatch;
found : Array[Int]
required: Array[? with Object]
Note: Int >: ? with Object, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: ? with Object`. (SLS 3.2.10)
AO_1.f(a)
^
Test_2.scala:5: error: type mismatch;
found : Array[Int]
required: Array[Int]
Note: Int >: Int, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10)
AO_1.f[Int](a)
^
two errors found
@@ -0,0 +1,5 @@
public class AO_1 {
public static <T> void f(T[] ar0) {
System.out.println(ar0);
}
}
@@ -0,0 +1,6 @@
// t750
object Test extends App {
val a = Array(1, 2, 3)
AO_1.f(a)
AO_1.f[Int](a)
}
View
@@ -0,0 +1,15 @@
Test.scala:4: error: type mismatch;
found : Array[Int]
required: Array[? with Object]
Note: Int >: ? with Object, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: ? with Object`. (SLS 3.2.10)
AO.f(a)
^
Test.scala:5: error: type mismatch;
found : Array[Int]
required: Array[Int]
Note: Int >: Int, but class Array is invariant in type T.
You may wish to investigate a wildcard type such as `_ >: Int`. (SLS 3.2.10)
AO.f[Int](a)
^
two errors found
@@ -0,0 +1,5 @@
public class AO {
public static <T> void f(T[] ar0) {
System.out.println(ar0);
}
}
@@ -0,0 +1,6 @@
// t750
object Test extends App {
val a = Array(1, 2, 3)
AO.f(a)
AO.f[Int](a)
}

0 comments on commit 5ca799d

Please sign in to comment.