Skip to content

Make consume a soft modifier #23755

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 15, 2025

Internally, it is still represented as an annotation.

Based on #23709

@odersky odersky requested a review from a team as a code owner August 15, 2025 14:13
@odersky odersky force-pushed the change-consume branch 2 times, most recently from c529d9a to b89eb41 Compare August 15, 2025 14:34
@odersky odersky requested a review from bracevac August 15, 2025 14:41
odersky and others added 17 commits August 15, 2025 17:03
 - Split doc page into individual sub-pages
 - Add new material on classifiers
 - Revise material on scoped caps

TODO

 - Revise material on reach capabilities
 - Add material on how to use the capture checker
 - Add material on separation checking
 - Check everything for completeness and accuracy

Also: Add two test files named `reference-cc.scala` in neg and pos that let us try out the code on the doc pages.

TODO: Complete these files so that all relevant code is there.
Files should also be listed in sidebar.yml.
Replaced hand-written intra-doc links with automatic doctool linking.
Sidebar now reflects the subsection hierarchy.
Also remove redundant headings
The first paragraph of a doc page is rendered
as some sort of synopsis/subtitle, which looked
awkward with the current text. This change adds
introduction headings, which also improves the
navigation on the right-hand side of a page.
This has to be in sync with `docs/sidebar.yml`
& let the root document be an index, consistent with
the style of other chapters of the reference.

There is also no need to manually write the ToC
with an index page.
Internally, it is still represented as an annotation
@@ -995,6 +995,10 @@ class Namer { typer: Typer =>
end if
}

private def normalizeFlags(denot: SymDenotation)(using Context): Unit =
if denot.is(Method) && denot.hasAnnotation(defn.ConsumeAnnot) then
denot.setFlag(Mutable)
Copy link
Member

Choose a reason for hiding this comment

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

This means that scaladoc will always render consume update instead of consume.
It will have to be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that would be nice to fix on scaladoc. Currently consume update is allowed, but the update is redundant.

Copy link
Member

@hamzaremmal hamzaremmal Aug 15, 2025

Choose a reason for hiding this comment

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

Currently consume update is allowed, but the update is redundant

I see what I can do to make it also a warning. The scaladoc fix is trivial.

hamzaremmal added a commit that referenced this pull request Aug 16, 2025
With the given example:

```scala
import caps.consume

import scala.language.experimental.captureChecking

class Test extends caps.Mutable:
    @consume def test(@consume x: Int)(using @consume y: Int): Unit = ()
```

It renders as following:

<img width="1051" height="281" alt="Screenshot 2025-08-15 at 16 11 05"
src="https://github.com/user-attachments/assets/022e5c58-827f-42ec-bdd7-938d019f2678"
/>

Related to #23755
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

Successfully merging this pull request may close these issues.

3 participants