Open
Description
reproduction steps
using Scala 2.13.3, 2.12.12, 2.11.12
Welcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 1.8.0_222).
Type in expressions for evaluation. Or try :help.
scala> :paste
// Entering paste mode (ctrl-D to finish)
object Test extends App {
trait Box[A] { self =>
type T
def zip(f: Box[A]) = new Box[A] { type T = (self.T, f.T) }
}
def opaqueBox[A]: Box[A] = new Box[A] { type T = Int }
def intBox[A] = new Box[A] { type T = Int }
trait Base {
val box: Box[String] // works: Box[Int]
def m(x: box.T): Int
}
class Impl extends Base {
import language.existentials
val box = opaqueBox[String].zip(intBox[String]) // works: opaqueBox[Int].zip(intBox[Int])
//box: Box[String]{type S = (_1.S, Int)} forSome { val _1: Box[String] }
def m(x: box.T) = x._2
}
val a: Base = new Impl
val x = (0, 0).asInstanceOf[a.box.T]
println(a.m(x))
}
// Exiting paste mode, now interpreting.
object Test
scala> Test.main(Array.empty)
java.lang.AbstractMethodError: Test$Impl.m(Ljava/lang/Object;)I
at Test$.delayedEndpoint$Test$1(<pastie>:23)
at Test$delayedInit$body.apply(<pastie>:1)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1(App.scala:73)
at scala.App.$anonfun$main$1$adapted(App.scala:73)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:553)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:551)
at scala.collection.AbstractIterable.foreach(Iterable.scala:920)
at scala.App.main(App.scala:73)
at scala.App.main$(App.scala:71)
at Test$.main(<pastie>:1)
... 40 elided
problem
Bridge method for m(x: Object)
in Impl
is not generated, causing the AbstractMethodError.
Changing to Box[Int]
makes it work, which is surprising because this does not change the erasure of m
(actually A
in Box[A]
is never used here, but its presence is mandatory to trigger the issue).