This page is no longer maintained — Please continue to the home page at www.scala-lang.org

2.8.0 and explicit implicit import fails

1 reply
Blair Zajac
Joined: 2009-01-12,
User offline. Last seen 42 years 45 weeks ago.

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

Blair Zajac
Joined: 2009-01-12,
User offline. Last seen 42 years 45 weeks ago.
Re: 2.8.0 and explicit implicit import fails

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

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland