Open
Description
The residual, and hard-to-fix, part of #10334. scala/scala#5977 restored parity with 2.11 with respect to the way this problem manifest with lambdas, but the core issue remains unsolved:
def t3(): Unit = {
val f1 = new T[A] {
def m(x: A) = "f1-a"
def m(x: B) = "f1-b"
// the m(Object)Object bridge method invokes (A)Object
}
val f2 = new T[B] {
def m(x: A) = "f2-a"
def m(x: B) = "f2-b"
// the (Object)Object bridge method invokes (B)Object
}
val g1: T[C] = f1
val g2: T[C] = f2
assert(g1.m(new C) == "f1-a")
assert(g2.m(new C) == "f2-b")
val s1: { def m(s: C): Object } = g1
val s2: { def m(s: C): Object } = g2
// the reflective lookup doesn't find `m(C)Object`
try {
s1.m(new C) // should invoke `m(A)Object`
throw new Error()
} catch {
case _: java.lang.NoSuchMethodException =>
}
// the reflective lookup doesn't find `m(C)Object`
try {
s2.m(new C) // should invoke `m(B)Object`
throw new Error()
} catch {
case _: java.lang.NoSuchMethodException =>
}
}