summaryrefslogtreecommitdiff
path: root/test/files/pos/javaReadsSigs
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-28 20:07:02 +0000
committerPaul Phillips <paulp@improving.org>2011-03-28 20:07:02 +0000
commit214a04461b78814b8498ea5a6d1cbbd71d9a6ab3 (patch)
tree134225c24b1efccf1ff11e14a8c056c01f10f2ef /test/files/pos/javaReadsSigs
parentd4392e047b61cc135f5110bf7863ec0d3480eaa6 (diff)
downloadscala-214a04461b78814b8498ea5a6d1cbbd71d9a6ab3.tar.gz
scala-214a04461b78814b8498ea5a6d1cbbd71d9a6ab3.tar.bz2
scala-214a04461b78814b8498ea5a6d1cbbd71d9a6ab3.zip
Expanding the test which tries to use the colle...
Expanding the test which tries to use the collections from java. No review.
Diffstat (limited to 'test/files/pos/javaReadsSigs')
-rw-r--r--test/files/pos/javaReadsSigs/fromjava.java69
1 files changed, 60 insertions, 9 deletions
diff --git a/test/files/pos/javaReadsSigs/fromjava.java b/test/files/pos/javaReadsSigs/fromjava.java
index d31244bb95..b1ffc34c11 100644
--- a/test/files/pos/javaReadsSigs/fromjava.java
+++ b/test/files/pos/javaReadsSigs/fromjava.java
@@ -1,16 +1,67 @@
+import scala.*;
+import scala.math.Ordering;
+import scala.math.Numeric;
+import scala.collection.Seq;
+import scala.collection.Traversable;
+import scala.collection.Traversable$;
+import scala.collection.immutable.Set;
+import scala.collection.immutable.HashSet;
+import scala.collection.immutable.Map;
+import scala.collection.immutable.Map$;
+import scala.collection.immutable.HashMap;
import scala.collection.immutable.Vector;
import scala.collection.immutable.List;
+import scala.collection.generic.CanBuildFrom;
-public class fromjava {
+class A { };
+class B { };
+
+// This one compiles but it would be better if it didn't.
+// Checking in under pos anyway in the interests of making sure
+// we are informed if the status changes.
+class Contra {
+ // Not an Ordering<Character>.
+ static Ordering<Object> charOrd = scala.math.Ordering$Char$.MODULE$;
+
+ public boolean useCharOrd() {
+ return charOrd.compare(new Object(), new Object()) == 0;
+ }
+
+ static Numeric<?> intNum = scala.math.Numeric$IntIsIntegral$.MODULE$;
+}
- void main(String[] args, Vector<String> x) {
- Vector<String> y = x.take(2);
- String h = y.head();
- System.out.println(h);
+public class fromjava {
+ public static Function1<A, B> f1 = new scala.runtime.AbstractFunction1<A, B>() {
+ public B apply(A a) {
+ return null;
}
- void main(String[] args, List<String> x) {
- List<String> y = x.drop(2);
- String h = y.head();
- System.out.println(h);
+ };
+
+ public static Function1<Tuple2<? extends Object, B>, B> f2 = new scala.runtime.AbstractFunction1<Tuple2<? extends Object, B>, B>() {
+ public B apply(Tuple2<? extends Object, B> tup) {
+ return tup._2();
}
+ };
+
+ public static String vector(Vector<String> x) {
+ Vector<String> y = x.take(2);
+ return y.head();
+ }
+ public static String list(List<String> x) {
+ List<String> y = x.drop(2);
+ return y.head();
+ }
+ public static Tuple2<String, Integer> map(Map<String, Integer> x) {
+ Traversable<Tuple2<String, Integer>> y = x.drop(2);
+ return y.head();
+ }
+ public static <T> Object sum(Traversable<T> x) {
+ return x.sum(Contra.intNum);
+ }
+ // can't make this work with an actual CanBuildFrom: see #4389.
+ public static B sum(Traversable<A> x) {
+ // have to cast it unfortunately: map in TraversableLike returns
+ // "That" and such types seem to be signature poison.
+ return ((Traversable<B>)x.map(f1, null)).head();
+ }
} \ No newline at end of file