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
For migration to 3, accommodate case companion as function #10648
Conversation
Oh wait, why add a feature that is deprecated right away? 🤔 |
Not sure about knobs for enablement yet, but Scala 3 warns about apply insertion. It's strictly a migration mitigation. |
blocked by #10573 |
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.
LGTM 👍 thanks!
|
@joroKr21 iirc the tupled case is not handled because scala 2 doesn't do parameter untupling adaptation. I'll try to nail it down while polishing. The other missing parts are compose & andThen, so the adaptation here is incomplete in that sense. So really, we're just trying to make it easier for those slick users. I used slick once, do I have to try it again to test out the use case? 😿 |
@lrytz about to contribute a bit of doc for the incompatibility matrix as you pointed out. I haven't tried it, but maybe it makes sense to support It was interesting that the recommended idiom is what is implemented here. |
Since this doesn't currently work on Scala 2, and only works in Scala 3 with a warning and is therefore discouraged, I don't think this is needed. |
My case for
Also, as @joroKr21 pointed out, this is true of everything in this PR. It has limited shelf life, as was true for the Scala 3 feature when it was introduced recently. |
OK, good point |
Not sure I'll get around to tupled. |
This comment was marked as resolved.
This comment was marked as resolved.
d1986de
to
0996ac6
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.
LGTM once the details are worked out
e897b8a
to
751a250
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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.
This LGTM, let me know if you want to add anything or we can merge.
@lrytz added a commit for "insert apply with tupling adaptation". It's a bit tricky (subtle), so it is unsquashed. I re-enabled the lrytz maneuver for your convenience. (Feel free to push here again.) Perhaps there is better API usage for the simple questions in Slightly augmented tests. My takeaway vis-a-vis TDD is that for a code change of a certain complexity, discipline is required to add tests for intersecting cases. I don't evince that discipline here. A nice IDE tool would be a test generator that probes feature interactions, scalacheck + fuzzing + chatgpt. It's nice to have the community build, but we could use the corpus to generate targeted tests (because we know how people use case classes and tupled, for instance). Oh, I just thought of another test. Edit: I checked that |
393e77e
to
d8958d0
Compare
Rebased and added support for The first typecheck of Note: using wildcard first emits spurious warning about "empty application" of Also added test for overloaded apply. Instead of erroring nicely, it just works because expected type is used first. |
d8958d0
to
f57bef9
Compare
This comment was marked as resolved.
This comment was marked as resolved.
/rebuild |
wasn't sure if |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@som-snytt can you do a round of making the PR description user-facing? I think it would be valuable to include an example, and to explicitly say what the behavior is on |
Scala 2 sometimes makes the companion object of a case class extend
Function
; Scala 3 does not, but includes other adaptations which are backported under-Xsource:3-cross
and allow the following idioms with reduced ceremony:Under
-Xsource:3
, using the case class companion as a function will warn.Backports Dotty migration support of case class companions by inserting
apply
. Dotty does not automatically addFunction
as a parent of the companion; for Scala 2 under-Xsource:3-cross
, follow Dotty but also adapt where the companion is not already aFunction
.Since Scala 2 lacks parameter untupling, also support explicit
C.tupled
and for completenessC.curried
.Fixes scala/bug#3664