Skip to content
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.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instance not found in 3.4.0 without -source:3.3 #655

Closed
joan38 opened this issue Mar 1, 2024 · 9 comments · Fixed by #656
Closed

instance not found in 3.4.0 without -source:3.3 #655

joan38 opened this issue Mar 1, 2024 · 9 comments · Fixed by #656

Comments

@joan38
Copy link

joan38 commented Mar 1, 2024

//> using scala 3.4.0
//> using dep org.typelevel::kittens:3.2.0

import cats.kernel.Monoid
import cats.derived.auto.monoid.given

case class B(a: Option[Int])
case class A(b: Option[B])

val _ = Monoid[A].empty

In Scala 3.4.0 yelds:

[error] No given instance of type cats.derived.DerivedMonoid[scala$minus3$u002E4$minusbug$_.this.A] was found.

Workaround:
Add this everywhere it fails to compile:

import scala.language.`3.3`

See: scala/scala3#19835

@joroKr21
Copy link
Member

joroKr21 commented Mar 1, 2024

I wonder if this was foreshadowed by #582
But there was no explanation really.

@joan38
Copy link
Author

joan38 commented Mar 8, 2024

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

@joan38
Copy link
Author

joan38 commented Mar 8, 2024

But the following works fine lol:

import cats.derived.auto.semigroup.given_Semigroup_A

But not:

import cats.derived.auto.semigroup.given Semigroup[?]

@joroKr21
Copy link
Member

joroKr21 commented Mar 9, 2024

Can you post a full example? That sounds like a bug in the linter because you are using the import.

@joan38
Copy link
Author

joan38 commented Mar 9, 2024

Ah I was trying to reproduce unsuccessfully but I forgot the scalacOptions.
Here is the reproduction: https://scastie.scala-lang.org/Po0uhQLgSjyzEdnffZLi1g

@joroKr21
Copy link
Member

I think it's kinda right because you also import monoid.given which takes priority

@joan38
Copy link
Author

joan38 commented Mar 10, 2024

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[?]

?

@joroKr21
Copy link
Member

joroKr21 commented Mar 10, 2024

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]].

@joroKr21
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants