title: Confusing type mismatch in Scala
body: <p>I have:</p>
  
  <pre><code>val words = List("all", "the", "words", "all", "the", "counts", "all", "day")
  val map = Exercise02.count(words.iterator)
  val expected = Map("all" -&gt; 3, "the" -&gt; 2, "words" -&gt; 1, "counts" -&gt; 1, "day" -&gt; 1)
  </code></pre>
  
  <p>where <code>Exercise02.count</code> is <code>java.util.Iterator[String] =&gt; Map[String, Int]</code> and merely produces a count of each word in the input <code>java.util.Iterator[String]</code>.</p>
  
  <p>I wrote a test:</p>
  
  <pre><code>object Exercise02Spec extends FlatSpec with Inspectors {
    val words = List("all", "the", "words", "all", "the", "counts", "all", "day")
    val map = Exercise02.count(words.iterator)
    val expected = Map("all" -&gt; 3, "the" -&gt; 2, "words" -&gt; 1, "counts" -&gt; 1, "day" -&gt; 1)
  
    "count" should "count the occurrence of each word" in {
      forAll (map) { kv =&gt; assert(kv._2 === expected(kv._1)) }
      // forAll (map) { (k: String, v: Int) =&gt; assert(v === expected(k)) }
    }
  }
  </code></pre>
  
  <p>The first line compiles just fine, and the test passes. If I replace the first line with the commented out second line, I get a compilation error.</p>
  
  <ul>
  <li>sbt reports: <code>found : (String, Int) =&gt; Unit, required: ((String, Int)) =&gt; Unit</code></li>
  <li>IntelliJ IDEA reports: <code>Type mismatch, expected: ((String, Int)) =&gt; Unit, actual: (String, Int) =&gt; Unit</code></li>
  </ul>
  
  <p>Why is this? And how do I fix it?</p>