Skip to content

Inference failure with -Ypartial-unification #13082

@lrytz

Description

@lrytz

Not sure if it's a bug, or if there are fundamental reasons why inference cannot succeed.

object Q {
  def f[T, F[X <: T]](s: F[T])(implicit c: Co[T, F]) = ???
}

trait Itr[+A]

trait Co[U, -F[_ <: U]]
object Co {
  implicit def i[E]: Co[E, Itr] = ???
}

class K
object K extends VS[K, VH[K]]

trait VS[V, H <: VH[V]] extends Itr[V]
trait VH[+A]

class Test {
  // these all work with 2.12, but fail with 2.13
  // they also fail with Scala 3, and with 2.12 with -Ypartial-unification
  //    inferred kinds of the type arguments (VH[K],[H <: VH[V]]VS[K,H]) do not conform to the expected kinds of the type parameters (type T,type F).
  //    [H <: VH[V]]VS[K,H]'s type parameters do not match type F's expected parameters:
  //    type H's bounds <: VH[V] are stricter than type X's declared bounds <: T
  Q.f(K)
  // Q.f(K)(Co.i)
  // Q.f(K)(Co.i[K])
  // Q.f(K)(Co.i[K])

  // works on 2.12, 2.13, Scala 3
  // Q.f[K, Itr](K)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions