What is it that makes the following code produce a compile error in Scala 2.11?
class Foo {
def fn(a: Seq[Int], b: Int => Int) {}
// Comment this line out
def fn(a: Map[String, String], c: String => Double) {}
}
object Bar {
def main(args: Array[String]) {
val f = new Foo()
f.fn(Seq(1, 2), _ * 2)
}
}
Error:
Error:(9, 21) missing parameter type for expanded function ((x$1) => x$1.$times(2))
f.fn(Seq(1, 2), _ * 2)
^
but yet the code compiles if the Map[String, String], String => Double
version of fn
is commented out. I can easily work round this by giving the compiler a hint or two, but I never like having to explicitly specify types in Scala :-)
(Aside: I'm aware method overloading is frowned on in Scala)