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
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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.
Compiler version
3.1.3 and 3.2.0-RC1
Minimized code
runnable: https://scastie.scala-lang.org/mIVAeZ5HSMCazZQlFl9qHQ
Output
Note that the type
Monoid
should be inferred to_Monoid
as a result of picking upGetMonoidType.getMonoid
, however it's not, and the search is performed on an uninstantiated type variableMonoid
, instead of on_Monoid[Int]
and cannot succeed.Expectation
Expected to work, as in Scala 2: https://scastie.scala-lang.org/AXiXnf60R8K2CRaOMm7g8A
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: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
The text was updated successfully, but these errors were encountered: