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
20|TC.check(x2)
|^|no implicit argument of typeTC[([+A] =>Foo.WithList[String, A])] was found for parameter F of method check in objectTC.
|Ifound:
||Foo.instance[Nothing]
||But method instance in objectFoo does not matchtypeTC[([+A] =>Foo.WithList[String, A])].
expectation
This is a minimization from the Cats tests, and the Scala 2 equivalent (using either kind-projector or ({ type L[x] = ... })#L for the type lambda) has no problems with this code.
Note that removing the variance annotation on the A in WithList resolves the issue for Dotty, but this isn't an option for Cats.
The text was updated successfully, but these errors were encountered:
If we change the result type of instance to take a type lambda with a covariant type parameter (implicit def instance[E]: TC[[+x] =>> Foo[E, x]]), then TC.check(x2) works ... but TC.check(x1) doesn't work anymore. The problem is that we instantiate F to some type lambda with a specific variance before doing the implicit search, but if we guess wrong we won't find the typeclass instance.
More precisely, constraint solving ends up with:
?F>: [+A] =>Foo.WithList[String, A] <: [A] =>Any
If we leave ?F like this we risk ambiguous errors in implicit search, so currently we instantiate it:
?F:= [+A] =>Foo.WithList[String, A]
but maybe we could be less strict and leave the variance to be resolved by implicit search:
Hopefully that strikes a good balance between making implicit search too wide (and therefore finding multiple candidates) vs making it too narrow (and therefore not finding anything).
minimized code
Compilation output
expectation
This is a minimization from the Cats tests, and the Scala 2 equivalent (using either kind-projector or
({ type L[x] = ... })#L
for the type lambda) has no problems with this code.Note that removing the variance annotation on the
A
inWithList
resolves the issue for Dotty, but this isn't an option for Cats.The text was updated successfully, but these errors were encountered: