- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
2.8.0 and explicit implicit import fails
Sat, 2009-11-07, 07:10
Using r19410 importing a single implicit def fails:
scala> import scala.collection.JavaConversions.asMap
import scala.collection.JavaConversions.asMap
scala> val sm : scala.collection.Map[Int,Int] = new java.util.HashMap[Int,Int]
:5: error: type mismatch;
found : java.util.HashMap[Int,Int]
required: scala.collection.Map[Int,Int]
val sm : scala.collection.Map[Int,Int] = new java.util.HashMap[Int,Int]
but importing all the implicits works:
scala> import scala.collection.JavaConversions._
import scala.collection.JavaConversions._
scala> val sm : scala.collection.Map[Int,Int] = new java.util.HashMap[Int,Int]
sm: scala.collection.Map[Int,Int] = Map()
Is this a bug?
Could this be due to the fact that there are two asMap's defined in
scala.collection.JavaConversions?
Regards,
Blair
On Nov 6, 2009, at 10:09 PM, Blair Zajac wrote:
> Using r19410 importing a single implicit def fails:
>
>
> scala> import scala.collection.JavaConversions.asMap
> import scala.collection.JavaConversions.asMap
>
> scala> val sm : scala.collection.Map[Int,Int] = new java.util.HashMap
> [Int,Int]
> :5: error: type mismatch;
> found : java.util.HashMap[Int,Int]
> required: scala.collection.Map[Int,Int]
> val sm : scala.collection.Map[Int,Int] = new java.util.HashMap
> [Int,Int]
>
>
> but importing all the implicits works:
>
>
> scala> import scala.collection.JavaConversions._
> import scala.collection.JavaConversions._
>
> scala> val sm : scala.collection.Map[Int,Int] = new java.util.HashMap
> [Int,Int]
> sm: scala.collection.Map[Int,Int] = Map()
>
>
> Is this a bug?
After chatting on IRC, Paul Philips also thought that this may be a
bug, so I opened:
https://lampsvn.epfl.ch/trac/scala/ticket/2591
Blair