Closed
Description
This is a replacement for code that uses type projections in Scala 2:
trait Base[D <: Domain] {
def f(pp: Extract[D]): Unit
}
class Ext extends Base[ExtDomain] {
def f(pp: String) = println(pp.length)
}
type Domain
type DomainImpl[T] <: Domain
type ExtDomain = DomainImpl[String]
type Extract[X] = X match { case DomainImpl[t] => t }
@main
def domainTest: Unit = {
def f[M <: Domain](rc: Base[M], v: Extract[M]): Unit = rc.f(v)
f(new Ext, "foo")
}
It fails with
java.lang.AbstractMethodError: Ext.f(Ljava/lang/Object;)V
Tested with 0.25.0-RC2 and 0.26.0-bin-20200719-21a90aa-NIGHTLY.