title: Scala function accepts different type
body: <p>I am trying to figure out why the following Scala code compile?</p>
  
  <pre><code>trait List[+A]
  case object Nil extends List[Nothing]
  case class Cons[+A](head: A, tail: List[A]) extends List[A]
  
  def map[A, B](as: List[A])(f: A =&gt; B): List[B] = as match {
    case Nil         =&gt; Nil
    case Cons(x, xs) =&gt; Cons(f(x), map(xs)(f))
  }
  
  def tester[A, B](as: List[A])(f1: A =&gt; List[B]) = map(as)(f1)
  </code></pre>
  
  <p>As per my understanding, <code>tester</code> should not compile because the definition of <code>map</code> says it accepts two parameters: a list list a function of type <code>A =&gt; B</code>.</p>
  
  <p>However, in <code>tester</code> function I have function <code>f1</code> which is of type <code>A =&gt; List[B]</code>, so, as the type of the arguments mismatch, I thought that the compiler should throw error. But the code is compiling fine.</p>
  
  <p>Could you please help me to understand why the code is compiling here?</p>