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

Expand value references to packages to their underlying package objects #22011

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 22, 2024

A package object can be seen as the facade of a package. For instance, it is the logical place where we want to write doc comments that explain a package.

So far references to packages cannot be used as values. But if the package has a package object, it would make sense to allow the package reference with the meaning that it refers to this object. For instance, let's say we have

package a
object b

Of course, we can use a.b as a value. But if we change that to

package a
package object b

we can't anymore. This PR changes that so that we still allow a reference a.b as a value to mean the package object. Due to the way package objects are encoded the a.b reference expands to a.b.package.

@odersky odersky marked this pull request as draft November 22, 2024 16:05
@tgodzik tgodzik added needs-minor-release This PR cannot be merged until the next minor release area:experimental and removed needs-minor-release This PR cannot be merged until the next minor release labels Nov 25, 2024
@odersky odersky force-pushed the add-package-object-values branch from 97fa8ff to f6c6dfa Compare November 25, 2024 17:54
@tgodzik tgodzik added the needs-sip A SIP needs to be raised to move this issue/PR along. label Jan 22, 2025
A package object can be seen as the facade of a package. For instance, it is the logical
place where we want to write doc comments that explain a package.

So far references to packages cannot be used as values. But if the package has a package
object, it would make sense to allow the package reference with the meaning that it refers
to this object. For instance, let's say we have

```scala
package a
object b
```
Of course, we can use `a.b` as a value. But if we change that to
```scala
package a
package object b
```
we can't anymore. This PR changes that so that we still allow a reference `a.b`
as a value to mean the package object. Due to the way package objects are encoded
the `a.b` reference expands to `a.b.package`.
@odersky odersky force-pushed the add-package-object-values branch from 944425d to 4429fd1 Compare February 16, 2025 09:44
@odersky odersky requested a review from smarter February 16, 2025 09:45
@odersky odersky added stat:sip-in-progress and removed needs-sip A SIP needs to be raised to move this issue/PR along. labels Feb 16, 2025
@odersky odersky marked this pull request as ready for review February 16, 2025 09:46
@odersky
Copy link
Contributor Author

odersky commented Feb 16, 2025

This is the experimental implementation of SIP 68

 - Instead of "Dropped: package objects" have a new doc page "Toplevel Definitions"
   in "other new features".
 - Add a doc page for experimental reference-able package object, which uses some
   wording from the Pre-SIP.
@odersky odersky force-pushed the add-package-object-values branch from 4429fd1 to 6e07688 Compare February 16, 2025 10:52
@@ -123,7 +123,6 @@ subsection:
- page: reference/dropped-features/type-projection.md
- page: reference/dropped-features/do-while.md
- page: reference/dropped-features/procedure-syntax.md
- page: reference/dropped-features/package-objects.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page will still show up in google search results, so eventually it will need to have a comment mentioning it's outdated pointing to the new doc.

@odersky odersky merged commit fb66f34 into scala:main Feb 21, 2025
29 checks passed
@odersky odersky deleted the add-package-object-values branch February 21, 2025 15:57
@lihaoyi
Copy link
Contributor

lihaoyi commented Feb 22, 2025

@odersky is this out in any nightly version that people can try out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants