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

Enable -Xsource:3 #1584

Open
ghostbuster91 opened this issue Sep 12, 2024 · 5 comments
Open

Enable -Xsource:3 #1584

ghostbuster91 opened this issue Sep 12, 2024 · 5 comments
Assignees
Milestone

Comments

@ghostbuster91
Copy link
Contributor

This should be enabled for both scala 2.12 and 2.13 builds.
It ensures that the code behaves in the same way across all language versions.

This fixes a bug in scala 2.12 and 2.13 where copy method is still accessible even though the primary constructor has been marked as private.

Above is binary incompatible change so I guess this goes into 0.19 series.

@ghostbuster91
Copy link
Contributor Author

I will happily volunteer for this.

@kubukoz
Copy link
Member

kubukoz commented Sep 12, 2024

I would suggest checking -Xsource:3-cross, apparently it's better suited for libs that are cross-built.

@Baccata
Copy link
Contributor

Baccata commented Sep 30, 2024

Go for it

@kubukoz kubukoz added this to the 0.19.0 milestone Sep 30, 2024
@ghostbuster91
Copy link
Contributor Author

ghostbuster91 commented Oct 7, 2024

As usual, it was easier said than done.

Turns out scala 2.12 does not support Xsource:3-cross atm. I asked if there are any plans to backport it here.

Without this we cannot use these new features like the improved semantics for copy modifiers, meaning that if we want to be better at preserving binary compatibility we have to stop using case classes in public api. Enabling it only for 2.13 & 3 doesn't make sense imo.

We could enable Xsource:3 that fails when a code with different semantics is detected but this isn't fully supported by scala 2.12 either as the following compiles without any errors/warnings:

//> using scala 2.12
//> using options -Xsource:3

case class Person private (age: Int, name: String)

@Baccata
Copy link
Contributor

Baccata commented Oct 7, 2024

we have to stop using case classes in public api

I agree that ideally this should be a goal. We even had started on it, but lay-offs and reprioritisations forced us to park this effort : #1391

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

No branches or pull requests

3 participants