In Scala 2.12.12 the following doesn’t compile (with or without -Ypartial-unification, which AFAICT has nothing to do with this anyway):
def f[T, A](x: T)(implicit ev: T =:= List[A]): List[A] = x
f(List(3))
whereas this works fine in Scala 2.13.3.
Reading the changelog I see a reference to type constructor inference:
Type inference has been extended to deal with type constructors, so that, in certain cases, you can omit type parameter lists that contain higher-kinded types (aka type constructors, e.g.,
List
).
Edit: Disregard, the above is from 2.10, not 2.13.
which is suggestive, and indeed the following, more cumbersome variant compiles in 2.12:
def f[T, F[_], A](x: T)(
implicit asF: T =:= F[A], ev: F[A] =:= List[A]): List[A] = asF(x)
f(List(3))
Does anyone have more information on what changed, and if this a new feature, are there any plans to backport it to 2.12 (I’d love to move to 2.13 or, even better, Dotty, but I can’t due to library dependencies)?
Addendum: The release notes mention SIP-2712 but the work on that issue seems to be for earlier Scala versions.