title: Why fold infers Any?
body: <p>I'm compiling with Scala 2.11.12 and this declaration:</p>
  <pre><code>import scala.collection.mutable.Stack
  def stackToInt(stack: Stack[Int]): Int =
    stack.zipWithIndex.fold(0){ case (z: Int, (piece: Int, index: Int)) =&gt;
      piece match {
        case 1 =&gt; (1 &lt;&lt; index) + z
        case _ =&gt; z
      }
    }
  </code></pre>
  <p>gives:</p>
  <pre><code>stack.zipWithIndex.fold(0){ case (z: Int, (piece: Int, index: Int)) =&gt;
                         ^
  error: type mismatch;
          found   : Any
          required: Int
  </code></pre>
  <p>I've been dealing with stuff like this many times when writing folds in this project (first one in Scala) and I always found a different way to make it work, but maybe if I understand it I will stop hitting this wall.</p>