object TheApp {
def main(args : Array[String]) {
implicit val innocentMap = Map("foo" -> Set("bar"))
"baz".nonEmpty
}
}
I tested it on 2.10, 2.11.8, 2.12.RC2 with same results.((TraversableOnce)innocentMap.apply("baz")).nonEmpty();
implicit val innocentMap = Map("foo" -> ("bar"))
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
Hi Gallus,this is not a bug, although it is not intuitive. One advice that removes a large class of such surprises is that you should never use implicits of primitive types or common collections thereof—the risk for having these picked up in the wrong context is just too high. In this case, since Map extends Function1 your implicit value is not innocent at all, because it presents another way how to turn a String into something that has a nonEmpty method.One thing that might be considered a bug is that declaring this value does not raise an implicit conversion warning—normally such dangerous activities are protected by a language feature import.