Description
Compiler version
Latest nightly
Minimized code
As noted in PR #22000, some expected subtyping
relations are still not supported.
import language.experimental.captureChecking
abstract class Source[+T, Cap^]:
def transformValuesWith[U](f: (T -> U)^{Cap^}): Source[U, Cap]^{this, f} = ???
def race[T, Cap^](sources: Source[T, Cap]^{Cap^}*): Source[T, Cap]^{Cap^} = ???
def either[T1, T2, Cap^](
src1: Source[T1, Cap]^{Cap^},
src2: Source[T2, Cap]^{Cap^}): Source[Either[T1, T2], Cap]^{Cap^} =
val left = src1.transformValuesWith(Left(_))
val right = src2.transformValuesWith(Right(_))
race(left, right) // <- rejected
//race[Either[T1, T2], Cap](left, right) // <- accepted
Expectation
The last line should not require explicit type arguments. This appears to be caused
by not being able to conclude Cap <: CapSet^{Cap^}
, but both sides
are morally equivalent.