scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Function parameter inference regression in 2.13 #12899

Closed lrytz closed 7 months ago

lrytz commented 7 months ago

2.13 regression when inferring function parameter types in an overloaded method call:

object Kafi {
  // OK in 2.12, fails in 2.13 with "missing parameter type for expanded function"
  val c1: Cache[(Seq[String], Class[_]), String] = build {
    case (sq, cs) => mk(sq, cs)
  }

  // OK in both 2.12 and 2.13
  val c2: Cache[(Seq[String], Class[_]), String] = build(
    key => mk(key._1, key._2)
  )

  def mk(sq: Seq[String], cs: Class[_]): String = ""

  def build[K, V](): Cache[K, V] = null
  def build[K, V](c: Cache[K, V]): Cache[K, V] = null

  trait Cache[K, V] { def load(k: K): V }
}

If some parameter is added to the the nilary build overload also fails on 2.12. So it's probably some pre-filtering by number of parameters that regressed. Interestingly, c2 keeps working also if both overloads have one parameter.