Higher-order unification for type constructor inference

Viewed 270
def meh[M[_], A](x: M[A]): M[A] = x
meh((x: Int) => "")

After SI-2712 (https://issues.scala-lang.org/browse/SI-2712) fix type A is inferred to the rightmost type parameter. In my example for Function1[Int,String] it is String.

How to make it inferred to left parameter?

And why this approach is not working?

class T[K,M]{}

def inferToLeft[S[_,_],K,B](ot: S[K,B]):({type Op[T] = S[T,B]})#Op[K]= ot

meh(inferToLeft(new T[Int,String]))

It's still inferred to String instead of Int

1 Answers
Related