You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Regression: invalid implicit search for an uninstantiated higher-kinded type variable is generated, even though the type variable should have been instantiated by previously found implicits #15915
Nogiveninstance of type_Monoid[Lifecycle[Int]] was found for parameter e of method implicitly in objectPredef.
Ifound:
Lifecycle.monoidForLifecycle[Monoid, Int](GetMonoidType.getMonoid,
/* missing */summon[Monoid[Int]]
)
But no implicit values were found that matchtypeMonoid[Int].
Note that the type Monoid should be inferred to _Monoid as a result of picking up GetMonoidType.getMonoid, however it's not, and the search is performed on an uninstantiated type variable Monoid, instead of on _Monoid[Int] and cannot succeed.
This is similar to #13986 in that it involves an HKT type variable not being instantiated correctly during implicit search.
Unlike that issue, there's a workaround for this one, via multiple using clauses:
implicitdefmonoidForLifecycle[Monoid[_], A](
using monoidType: GetMonoidType[Monoid]
)(usingmonoidA: Monoid[A]
):Monoid[Lifecycle[A]] =new _Monoid().asInstanceOf[Monoid[Lifecycle[A]]]
Note that due to #13986, setting a bound on the type variable Monoid[x] <: _Monoid[x] does not workaround the error.
This code is a minimized version of real library code in https://github.com/izumi/izumi which we're trying to port to Scala 3