-
Notifications
You must be signed in to change notification settings - Fork 21
Case companions no longer extend FunctionN
under -Xsource:3-cross
, breaking binary compatibility
#12961
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
Comments
@SethTisue mentioned the possibility of having separate flags for language changes adopted from Scala 3. This would help here:
So |
Oh, I wasn't thinking of going that far! I was thinking something like |
Sometimes you need versioned sources; that is the mechanism. We did not have a discussion, but I avoided the fine-grained feature selection as in Arguably, dotty I agree about silent semantics in The purpose of future source migration is to shake out the code base for migration to minimize pain as much as possible. (Pain could be maintaining two source versions or the pain of switching to dotty at some future point in time.) It's not a feature buffet. |
I don't think I understand your point here?
In an ordinary project, though, it would incredibly cumbersome to have versioned sources for all of your case classes, so I don't think that's a satisfying answer for this particular issue (case class companion parentage). |
oh btw big thanks to @mkurz for discovering and reporting this promptly (over at playframework/playframework#12401) |
|
Sample investment would be scala/scala#10648 "For migration to 3, accommodate case companion as function". Sample ticket where accommodation may (arguably) be unreasonable (because they are interested in piecemeal language forking): #12960 If we wanted forking options, we would introduce If
"I don't want to lose case companion parentage" is incompatible with "I want one version of my case class that cross-compiles." There's nothing wrong with, "We can't use |
-Xsource:3-cross
, breaks binary compatibilityFunctionN
under -Xsource:3-cross
, breaks binary compatibility
FunctionN
under -Xsource:3-cross
, breaks binary compatibilityFunctionN
under -Xsource:3-cross
, breaking binary compatibility
Ah, I see. Yes, good point. I strongly agree that we should keep in mind that the purpose of However, in this particular situation I think offering a la carte access might be justifiable, because we would be adding it exactly to allow people who were already cross-building to continue to cross-build. |
My other basic question is, why is "case companion breaks binary compat" different from "method result inference breaks binary compat". Both require tweaking source code (adding an object or an explicit type). Maybe |
This case companion issue is different because there is no workaround (besides the unreasonably cumbersome version-specific sources option, I mean). You cannot work around it by tweaking cross-compiled source code. At least, it didn't seem to me and Lukas that a workaround exists — are we mistaken? As Lukas wrote above,
|
I wrote "reasonable", but I may have meant "conceivable":
I guess that is just to say, Yes, if you want to cross-build, break binary compatibility. What do they call such a response in Intro to Rhetoric? In engineering, it is "cutting the Gordian knot". |
I see your point, but in reality we have to accomodate projects that are already cross-building and want to continue to do so on 2.13.13. Bumping the major version is a big step and it should not be required by a compiler upgrade. |
I finally remembered scala/scala-xml#675: the "inferred return type of an overriding method" change is also not easy to work around. Spelling out the 2.13 return type is not enough because that's a binary incompatible change on Scala 3. |
Oh good point, I should have thought of that. So if we end up doing the a-la-carte thing, I guess should make that one opt-out-able too. |
How about or Edit: I will PR (as POC)
However, override inference was on The nerd-sniping was on the ancient ticket: Previous to the |
I don't really follow, sorry. As far as I can tell, We have 2 problems to solve for
Maybe it looks overkill, but I'm currently thinking about a flag that replaces
|
By default, I think compilers should be silent. I think we should avoid warnings if it did exactly what was told (i.e. make semantic changes similar to Scala 3) and there is nothing actionable, as opposed to quickfixes that are actionable. As the code base gets larger in work settings, it should be assumed that the majority of the users probably will not read or notice compiler warnings because they're buried in existing warnings. It might be more helpful if there were authoritative guide like https://docs.scala-lang.org/scala3/guides/migration/tooling-scala2-xsource3.html highlighting changes in 2.13.x, and those who venture into the |
Speaking of the semantic changes, I feel like Scala 2.13.13 shifts the meaning of
Here's what I suggest to restore
|
Could we use |
To summarize, Also, I think just corralling the binary-compat issue is simpler than offering an option buffet. |
@eed3si9n yes, In a normal universe, all this would be in 2.14. The notion that the entire |
@som-snytt I do recognize the need for gentler
Update: Updated |
@eed3si9n Yes. Until I finish my coffee, I won't remember whether "override inference" was already
|
@lrytz actually, I don't wish to experiment. I'll try a simpler version of your overkill, which is to name the behaviors that can be opted-out under some separate flag. I would prefer to keep (Then it doesn't matter if "override inference" was introduced under As a reminder, |
Yea. One useful context is that circa So to either show warnings about newly introduced semantic changes etc, it seems logical to combine |
I agree, once you opt in to a Scala 3 language semantic there are no more warnings about it.
That's right, we now draw the line between warnings (fatal by default) for migration and adopting language changes (benign new syntax is enabled in migration mode). I still think that's the right distinction. There are many options for which flags to use for implementing that distinction, but at this point I think we should aim at minimizing change in 2.13.14. So I'd leave I'm not in favor overloading The issue we need to solve only affects library authors that cross-build. This is a small group of experts, that's why I think it's fine (and valuable) to give them the "buffet" flag. There's one adjustment we probably should do for 2.13.14 about any2stringadd: even under
|
Eugene's original |
Uh oh!
There was an error while loading. Please reload this page.
2.13.13 aligned synthetic case companions with Scala 3 to no longer
extend FunctionN
under-Xsource:3-cross
(scala/scala#10648).Projects that already have cross-published releases for Scala 2.13 and 3.x cannot adopt
-Xsource:3-cross
because this change is not binary compatible.The workaround of manually writing out
object C extends FunctionN
is not a solution because that source change would also affect Scala 3, causing a binary incompatibility there. (It would also be very tedious.)This situation can be a blocker for libraries to upgrade to Scala 2.13.13. Example:
-Xsource:3 -Xmigration
, the escape inraw"\u0042"
is not processed-Xsource:3-cross
. A project using-Xsource:3
needs to move to-Xsource:3-cross
to maintain semantics. With-Xsource:3
, the escape is now being processed.A more general question is how do we add further language changes to
-Xsource:3-cross
in the future. Every semantic change comes with a warning under-Xsource:3
. But projects that are already on3-cross
would silently get new semantics in a new Scala version.The text was updated successfully, but these errors were encountered: