Type constructor inference in Scala 2.13

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.

1 Like

That changelog quote is from 2010 (!).

2.13.0-M5 is the first version where this compiled, but nothing in the M5 release notes is jumping out at me, and we merged 417 PRs (!) for that release. Perhaps someone else will recognize it.

Yeah, my mistake, when I first posted this I missed the link to the release notes and assumed that the first changelog on that page belonged to 2.13, I didn’t realize it was 2.10 (wow).