I wrote this code
case class Foo(x: Int) case class Bar(y: Int) object Foo { implicit def toBar(f: Foo) : Bar = { Bar(f.x) } implicit def toBarList(fl: List[Foo]) : List[Bar] = {fl.map{x: Bar => x}} The toBarList function doesn't compile.
<console>:17: error: type mismatch; found : Bar => Bar required: Foo => ? implicit def toBarList(fl : List[Foo]) : List[Bar] = { fl.map{x : Bar => x}} However shouldn't the implicits system kick in here? meaning that compiler should detect that there is an error that the function expects a Bar but I am passing a Foo. Now there is already a implicit function in scope which converts Foo to a Bar, so that should be used and things should work.
So why did this not compile?
{fl.map{x: Bar => b}}, probably you meant{fl.map{x: Bar => x}}or{fl.map{b: Bar => b}}.