Closed joan38 closed 7 months ago
I wonder if this was foreshadowed by https://github.com/typelevel/kittens/pull/582 But there was no explanation really.
With kittens 3.3.0 I get some:
[error] 4 |import cats.derived.auto.semigroup.given
[error] | ^^^^^
[error] | unused import
Even on Scala 3.3.3
And if I don't given them, it fails to find the semigroups
But the following works fine lol:
import cats.derived.auto.semigroup.given_Semigroup_A
But not:
import cats.derived.auto.semigroup.given Semigroup[?]
Can you post a full example? That sounds like a bug in the linter because you are using the import.
Ah I was trying to reproduce unsuccessfully but I forgot the scalacOptions. Here is the reproduction: https://scastie.scala-lang.org/Po0uhQLgSjyzEdnffZLi1g
I think it's kinda right because you also import monoid.given
which takes priority
But having just import cats.derived.auto.monoid.given
does not work either.
So is there a way to make this work without importing by name the given? Something like:
import cats.derived.auto.monoid.given
import cats.derived.auto.semigroup.given
Or:
import cats.derived.auto.monoid.given Monoid[?]
import cats.derived.auto.semigroup.given Semigroup[?]
?
What do you mean by "does not work" though?
If I import cats.derived.auto.monoid.given
then Monoid[Rebuffers]
works.
If I import cats.derived.auto.semigroup.given
then Semigroup[Rebuffers]
works.
The only issue I can see is that if I import import cats.derived.auto.monoid.given
then Semigroup[Rebuffers]
doesn't work. I don't know why, but that's the same behaviour as Kittens 3.2:
No given instance of type cats.kernel.Semigroup[Playground.Rebuffers] was found for parameter ev of method apply in object Semigroup.
I found:
cats.derived.auto.monoid.given_Monoid_A[Playground.Rebuffers](
/* missing */
summon[scala.util.NotGiven[cats.kernel.Monoid[Playground.Rebuffers]]]
)
But no implicit values were found that match type scala.util.NotGiven[cats.kernel.Monoid[Playground.Rebuffers]].
Hmm, I guess that means the linter is wrong after all because the import is used. Ok, best to report this in Dotty, I don't think we can do anything here.
In Scala 3.4.0 yelds:
Workaround: Add this everywhere it fails to compile:
See: https://github.com/lampepfl/dotty/issues/19835