I've been doing scala coding on intellij idea. All was well until I added this piece of code (copied from https://stackoverflow.com/a/32380463/444644 ) :
def toJava(x: Any): Any = {
import scala.collection.JavaConverters._
x match {
case y: scala.collection.MapLike[_, _, _] =>
y.map { case (d, v) => toJava(d) -> toJava(v) } asJava
case y: scala.collection.SetLike[_,_] =>
y map { item: Any => toJava(item) } asJava
case y: Iterable[_] =>
y.map { item: Any => toJava(item) } asJava
case y: Iterator[_] =>
toJava(y.toIterable)
case _ =>
x
}
}
This results in two "error" highlights for the first two asJava calls above. But the code compiles and runs fine. How to fix it?