summaryrefslogtreecommitdiff
path: root/test/files/pos/t5580b.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-03-17 21:12:51 -0700
committerPaul Phillips <paulp@improving.org>2012-03-21 12:30:31 -0700
commit5d555ef90f443e20d2e46c668e456df0a643dae8 (patch)
treed365ed4fa541e53a5994917a8cbbb5db6f9b1630 /test/files/pos/t5580b.scala
parent39938bcc299644807a5d5fa4f4b528f9997fd505 (diff)
downloadscala-5d555ef90f443e20d2e46c668e456df0a643dae8.tar.gz
scala-5d555ef90f443e20d2e46c668e456df0a643dae8.tar.bz2
scala-5d555ef90f443e20d2e46c668e456df0a643dae8.zip
Overhaul of JavaConver{sions,ters}.
Initially motivated by SI-5580, then just motivated. I broke up the opaquely named JavaConversions and JavaConverters into the following traits encapsulating some permutation of { to java, to scala, bidirectional } { wrappers, decorators } I named everything consistently in terms of either Wrappers or Decorators. Decorators install those asJava/asScala methods onto collections of the right kind; Wrappers hide the process. JavaConversions then reduces to an object which (ill-advisedly) extends both WrapAsJava and WrapAsScala. And JavaConverters is an object extending DecorateAsScala and DecorateAsJava. However other more clearly named vals exist in the newly created scala.collection.convert package object. val decorateAsJava = new DecorateAsJava { } val decorateAsScala = new DecorateAsScala { } val decorateAll = new DecorateAsJava with DecorateAsScala { } val wrapAsJava = new WrapAsJava { } val wrapAsScala = new WrapAsScala { } val wrapAll = new WrapAsJava with WrapAsScala { } So for instance to import asScala decorators, and only those: scala> import scala.collection.convert.decorateAsScala._ import scala.collection.convert.decorateAsScala._ scala> new java.util.ArrayList[String].asScala groupBy (x => x) res0: scala.collection.immutable.Map[String,scala.collection.mutable.Buffer[String]] = Map() I propose we put those vals or a subset of them in the scala package object rather than way down in scala.collection.convert.
Diffstat (limited to 'test/files/pos/t5580b.scala')
-rw-r--r--test/files/pos/t5580b.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/pos/t5580b.scala b/test/files/pos/t5580b.scala
new file mode 100644
index 0000000000..d5a4a0a2b2
--- /dev/null
+++ b/test/files/pos/t5580b.scala
@@ -0,0 +1,19 @@
+/** It's a pos test because it does indeed compile,
+ * not so much because I'm glad it does. Testing
+ * that error messages created and discarded during
+ * implicit search don't blow it up.
+ */
+
+import scala.collection.mutable.WeakHashMap
+import scala.collection.JavaConversions._
+
+class bar { }
+
+class foo {
+ val map = WeakHashMap[AnyRef, collection.mutable.Map[bar, collection.mutable.Set[bar]]]()
+
+ def test={
+ val tmp:bar=null
+ if (map.get(tmp).isEmpty) map.put(tmp,collection.mutable.Set())
+ }
+}