-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Should top level definitions access their wrapper objects and members of Any from Predef? #7713
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
Indeed the enclosing package is as documented: "The compiler generates synthetic objects that wrap toplevel definitions." This
|
The OP didn't include the Scala 2 ticket scala/bug#5389 |
I bumped into this today. It's easy enough to avoid by adding the |
We discussed the semantic of accessing There are three main questions:
Before reading this issue and https://docs.scala-lang.org/scala3/reference/dropped-features/package-objects.html, I was thinking that generated synthetic objects for files should not be part of the mental model of developers and that we should answer "no" to 1. and 3. (disallow references to After reading them, the correct answer sounds less obvious to me. The documentation clearly states that generated synthetic objects for files are part of binary compatibility, and that you can As a first uncontroversial step, I would suggest to issue warnings for calls to both |
@mbovel item 2 is intriguing also because scala/scala#10220 (comment) This usage is ambiguous -- perhaps rightly so, because of the juxtaposition of the definition and usage. It would not be ambiguous if
|
Ticket was partially duplicated by #17266 and subsequent tweaks. The answer to the rhetorical question in the title is obviously not. |
minimized code
expectation
Scala 2 recently stopped including members of
Any
in root imports fromPredef
.That was previously visible in
import ne.scala
.Using
getClass
in a constructor context was noticed in Akka test code.Crafting a package from the compilation unit looks intentional here, so perhaps
this
is as well. And maybe there is nothing which saystoString
must meanthis.toString
in any context.The text was updated successfully, but these errors were encountered: