title: Scala unexpected type inference troubleshooting
body: <p>I'm struggling a long time with incorrect type inference of the <code>O</code> output type. Why does scalac see <code>Int</code> instead of <code>(Int,String)</code> ? : </p>
  
  <pre><code>trait Request[I,+O,C[_]]
  case class Get[I, O, C[_]](storeName: String, arg: C[I]) extends Request[I,(I,O),C]
  object Question {
    val get: Request[Int,(Int,String), List] = Get("play", List(1))
  }
  
  [error]  found   : com.viagraphs.idb.Get[Int,Int,List]
  [error]  required: com.viagraphs.idb.Request[Int,(Int, String),List]
  [error]       val get: Request[Int,(Int,String), List] = Get("play", List(1))
  </code></pre>
  
  <p>Please ignore <code>W,R,ValidKey</code> type classes, they are irrelevant here I guess.</p>
  
  <p>Exactly the same happens this way : </p>
  
  <pre><code>case class Append[I : W, O : R : ValidKey](storeName: String, arg: List[I]) extends Request[I,(O,I),List]
  object Question {
    val get: Request[Int,(Int,String), List] = Get("play", List(1))
  }
  val append: Request[String,(Int,String), List] = Append("play", List("foo"))
  
  [error]  found   : com.viagraphs.idb.Append[String,String]
  [error]  required: com.viagraphs.idb.Request[String,(Int, String),List]
  [error]       val append: Request[String,(Int,String), List] = Append("play", List("foo"))
  </code></pre>
  
  <p>I tried to deal with this using <code>-Ytyper-debug</code> but it is really hard core stuff, I didn't understand its mechanics.</p>
  
  <p>UPDATE: I reproduced it using Ordering type class, any idea what implicit resolution rule is not satisfied?</p>
  
  <pre><code>  trait Req[I,O]
    case class Insert[I : Ordering, O : Ordering](arg: I) extends Req[I,O]
    def execute[I,O](req: Req[I,O]): O = null.asInstanceOf[O]
  
    def main() = {
      val result: Int = execute(Insert("test"))  
    }
  
  error: type mismatch;
   found   : String
   required: Int
      val result: Int = execute(Insert("test"))  
  </code></pre>