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
Replace buildFromAny with buildFromNothing #4815
Conversation
Instead of generalizing to `Any` we need to specialize to `Nothing`. All other cases are covered by the default `BuildFrom.buildFromIterableOps`.
d35bfab
to
afc5611
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joroKr21 Are you having an issue here? I think that both definitions are sound, though they say slightly different things. At least on previous versions of Scala 2.13 this was necessary for a CanBuildFrom
to be in scope for certain operations. I haven't heard of any other problems with this to date.
@adamgfraser I go have a minor issue actually - Intellij also thinks the instances are ambiguous so it breaks highlighting. The reason is that there is overlap. |
@@ -6,7 +6,12 @@ private[zio] trait BuildFromCompat { | |||
|
|||
type BuildFrom[-From, -A, +C] = scala.collection.BuildFrom[From, A, C] | |||
|
|||
implicit def buildFromAny[Element, Collection[+Element] <: Iterable[Element] with IterableOps[Any, Collection, Any]] | |||
@deprecated("Use BuildFrom.buildFromIterableOps or buildFromNothing instead", "1.0.6") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to change this can we just delete it entirely instead of deprecating it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that be binary incompatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binary compatibility checks seem to be okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no - it loos like the MiMa checks job has been broken for some time 😱
https://circleci.com/api/v1.1/project/github/zio/zio/107145/output/104/0?file=true&allocation-id=605246e5efc352258c281098-0-build%2F701E1D91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or was that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamgfraser oh I see why - we check binary compatibility against 1.0.1 but this was added in 1.0.4-1: https://github.com/zio/zio/releases/tag/v1.0.4-1
Wow, I never really thought about this, but if you don't bump the version for MiMa that means you could accidentally delete something that you introduced in a later version. Amazing 🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I bump the version in MimaSettings
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes me think there should be some process or automation to bump this version on release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Not sure what the best way is to do it but that would definitely be good.
@joroKr21 That's a good reason! I'm good with this change as long as the tests pass. Would prefer to just delete the old instance if possible. |
I will also try to compile with |
Indeed compiling |
So how is it possible that it fails if we use |
I think |
No the |
AFAIR in dotty the package object doesn't contribute to implicit scope, so maybe that's the reason. |
But it still has the change in implicit resolution for contravariant types that was supposed to be what triggered this issue, right? |
And delete filters that are not needed anymore.
b2aa4fb
to
b8262ad
Compare
Yes it does, but if that instance is not in implicit scope it just won't be considered. |
But the instance isn't in the Dotty package, right? It is in the Scala collections which has got to be in implicit scope or everything else with |
The |
Right but that's true on Scala 3 as well. So why would it compile on Scala 3 but not on Scala 2 with implicit resolution rules from Scala 3? |
It's change number 3. here: https://dotty.epfl.ch/docs/reference/changed-features/implicit-resolution.html |
package p
given a: A = A()
object o:
given b: B = B()
type C
I'm a bit confused - so does it include package objects or not? |
I don't know. I guess what I take from this is that this |
Kind of raises an interesting question for library authors of whether we need to have this in our build matrix too. As we're seeing it is essentially a different version with different semantics of what compiles or not in some cases. If we did run against this in CI we would have caught before the PR adding this got merged. |
Indeed that's a good question. I don't think it's possible to port everything from Scala 3. On the other hand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work on this! 🙏
Instead of generalizing to
Any
we need to specialize toNothing
.All other cases are covered by the default
BuildFrom.buildFromIterableOps
.Also fixes Intellij highlighting issue.
See scala/bug#12350
Workaround for scala/bug#12104
Followup to #4582