Reproduction:
object Main {
final def main(args: Array[String]): Unit = {
val f: A => Any = { a =>
case class Case(abc: a.b.C)
foo(Case, new a.b.C)
}
println(f(new A(new B)))
}
def foo[A, B](f: A => B, a: A): B = f(a)
}
class A(val b: B)
class B {
class C
}
Scastie: http://scastie.org/29090
The companion object of Case, which extends Function1[a.b.C, Case], is missing its apply(Object)Object bridge. It only has apply(B$C)Case.
Moving the definition of Case outside of the lambda (but still inside main) causes it to run without error. And indeed, in that case, it has the appropriate bridge.
This only happens on 2.12 (tested with 2.12.1).
/cc @aholland