diff options
author | Paul Phillips <paulp@improving.org> | 2012-03-17 21:12:51 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-03-21 12:30:31 -0700 |
commit | 5d555ef90f443e20d2e46c668e456df0a643dae8 (patch) | |
tree | d365ed4fa541e53a5994917a8cbbb5db6f9b1630 /test/files/neg/t5580a.check | |
parent | 39938bcc299644807a5d5fa4f4b528f9997fd505 (diff) | |
download | scala-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/neg/t5580a.check')
-rw-r--r-- | test/files/neg/t5580a.check | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/files/neg/t5580a.check b/test/files/neg/t5580a.check new file mode 100644 index 0000000000..50a31857d5 --- /dev/null +++ b/test/files/neg/t5580a.check @@ -0,0 +1,6 @@ +t5580a.scala:9: error: polymorphic expression cannot be instantiated to expected type; + found : [A]scala.collection.mutable.Set[A] + required: scala.collection.mutable.Map[bar,scala.collection.mutable.Set[bar]] + if (map.get(tmp).isEmpty) map.put(tmp,collection.mutable.Set()) + ^ +one error found |