From 214a04461b78814b8498ea5a6d1cbbd71d9a6ab3 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 28 Mar 2011 20:07:02 +0000 Subject: Expanding the test which tries to use the colle... Expanding the test which tries to use the collections from java. No review. --- test/files/pos/javaReadsSigs/fromjava.java | 69 ++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 9 deletions(-) (limited to 'test/files') 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. + static Ordering 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 x) { - Vector y = x.take(2); - String h = y.head(); - System.out.println(h); +public class fromjava { + public static Function1 f1 = new scala.runtime.AbstractFunction1() { + public B apply(A a) { + return null; } - void main(String[] args, List x) { - List y = x.drop(2); - String h = y.head(); - System.out.println(h); + }; + + public static Function1, B> f2 = new scala.runtime.AbstractFunction1, B>() { + public B apply(Tuple2 tup) { + return tup._2(); } + }; + + public static String vector(Vector x) { + Vector y = x.take(2); + return y.head(); + } + public static String list(List x) { + List y = x.drop(2); + return y.head(); + } + public static Tuple2 map(Map x) { + Traversable> y = x.drop(2); + return y.head(); + } + public static Object sum(Traversable x) { + return x.sum(Contra.intNum); + } + // can't make this work with an actual CanBuildFrom: see #4389. + public static B sum(Traversable x) { + // have to cast it unfortunately: map in TraversableLike returns + // "That" and such types seem to be signature poison. + return ((Traversable)x.map(f1, null)).head(); + } } \ No newline at end of file -- cgit v1.2.3