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

Move catsTraverseForSeq to lower-priority implicit scope #4373

Merged
merged 4 commits into from
Jan 15, 2023

Conversation

UlisesTorrella
Copy link
Contributor

Hi, first (try)pr here. Trying to solve the bug at issue #4370.

I followed the idea to de-prioritize the Seq instance. Though it solves the issue mentioned, it prompts some other warnings at compilation time (I'm not sure it's specific to this change).

As told in the issue, I'll be reading a bit if there is another way around it, unless the solution is considered good enough.
Any ideas or directions are welcome.

@armanbilge
Copy link
Member

Thanks!

Though it solves the issue mentioned

How did you confirm this, were we getting the same warning in Cats itself?

it prompts some other warnings at compilation time (I'm not sure it's specific to this change).

Unfortunately the Cats build is currently full of warnings, so it's quite possible it's unrelated.

@@ -98,9 +98,13 @@ trait UnorderedFoldable[F[_]] extends Serializable {
unorderedFoldMap(fa)(a => if (p(a)) 1L else 0L)
}

trait LowPriorityImplicits {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
trait LowPriorityImplicits {
private trait UnorderedFoldableLowPriority {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw (late) that it couldn't be used later if it was private: private trait UnorderedFoldableLowPriority escapes its defining scope as part of type cats.UnorderedFoldableLowPriority
I changed it to protected, I think it makes sense, what do you think?

Co-authored-by: Arman Bilge <armanbilge@gmail.com>
@UlisesTorrella
Copy link
Contributor Author

Though it solves the issue mentioned

How did you confirm this, were we getting the same warning in Cats itself?

I replicated the error using the code from the issue, ran it in the repl and got the same warning that @bpholt mentions. Then made the change and ran it again without warnings. I didn't check if the same warning was anywhere in Cats itself

@armanbilge armanbilge added the bug label Jan 14, 2023
@armanbilge armanbilge linked an issue Jan 14, 2023 that may be closed by this pull request
@armanbilge armanbilge changed the title Tackling issue #4370 Move catsTraverseForSeq to lower-priority implicit scope Jan 14, 2023
private trait UnorderedFoldableLowPriority {
protected trait UnorderedFoldableLowPriority {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, was there a compile error if this was private? If so, we should make it private[cats], not protected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it failed with private trait UnorderedFoldableLowPriority escapes its defining scope as part of type cats.UnorderedFoldableLowPriority , I changed it to private[cats] and compiles. I'm running the prePR and I'll push it

Copy link
Member

@armanbilge armanbilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, much appreciated!

Copy link
Member

@danicheg danicheg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@armanbilge armanbilge merged commit bd0d7b8 into typelevel:main Jan 15, 2023
@UlisesTorrella UlisesTorrella deleted the issue#4370 branch January 15, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scala 3 Ambiguous Implicits in UnorderedFoldable
3 participants