-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fail compilation if multiple conflicting top-level private defs/vals are in the same package #22759
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
Conversation
Looks like the https://github.com/scala/scala3/blob/main/tests/neg/toplevel-overload/moredefs_1.scala test case claims otherwise |
community-build run results: https://virtuslab.github.io/community-build3/2025/03/12/3.7.0-rc1-20250310-f0284d0-snapshot.html |
At the core meeting we talked about making sure this also behaves like conflicting objects/classes would in separate compilation (where with the help of incremental compilation, they are able to throw the error), which I needed to recheck. It looks like it currently does not, even for public definitions: #22804. I think it should be safe to merge this anyway, since the error happened for public definitions too, and I do not believe this is something we can fix in the compiler itself (as I try to explain the the issue). |
…are in the same package (scala#22759) Now the private top level definitions act basically the same as package private (which is the same behavior as private objects/classes), as that is what the reference implies, and it helps us avoid ambiguous method/value selections.
…are in the same package (scala#22759) Now the private top level definitions act basically the same as package private (which is the same behavior as private objects/classes), as that is what the reference implies, and it helps us avoid ambiguous method/value selections. [Cherry-picked 8fe16fe][modified]
…are in the same package (scala#22759) Now the private top level definitions act basically the same as package private (which is the same behavior as private objects/classes), as that is what the reference implies, and it helps us avoid ambiguous method/value selections.
…are in the same package (scala#22759) Now the private top level definitions act basically the same as package private (which is the same behavior as private objects/classes), as that is what the reference implies, and it helps us avoid ambiguous method/value selections. [Cherry-picked 8fe16fe][modified]
Fixes #22721
Now the private top level definitions act basically the same as package private. To be honest, I am not completely certain that this is what's supposed to happen here, but:
Private top level definitions should be visible from other files (as long as they share a package), and if multiple share the same name, they should be in the same files (so it seems they should error out if found in different files).