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

Implement @use scheme #21740

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

Implement @use scheme #21740

wants to merge 11 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 9, 2024

  • Allow annotations like @use after capture types
  • Implement @use scheme:
    • We allow @use on parameter types.
    • If we narrow cap to a reach capability under a @use, the reach capability becomes use-declared.
    • We print such reach capabilities as x*@use for debugging.
    • A use-declared capability can leak into the method owner the parameter.
    • User-written reach capabilities of parameters whose type carries a @use annotation are also allowed to leak into the enclosing method..
    • On the other hand, if we pass an actual argument(-part) to (part-of) a formal parameter type that is annotated with @use, we charge the deep capture set of the argument to the currently enclosing environments.
  • Check that overridden methods are @use correct. This means if an overridden method has @use in some parameter types, the overriding method must have these parameter types under @use as well.
  • Drop previous @unbox schme.
  • Infer @use annotations. If a parameter has a type containing occurrences of cap and the parameter is not referred to from a function result, add an implied @use to the parameter type. The idea is that we'd pass a parameter with universal capturing type only if the parameter is either returned or used in the method. So if it is not returned we can infer an @use.
  • Generalize the scheme to also handle capture set variables in addition to reach capabilities.

noti0na1 and others added 11 commits September 25, 2024 21:45
This is done for comparing old with new
Add the path cases without changing the whole logic
If we refer to a path `a.b`, we should mark `a.b` as used,
which is better than marking `a`.
Needed to make stdlib2-cc go through.

There were two errors. One in LayListIterable required a type annotation
and a tweak to markFree. The other in Vieew.scala required a cast, but this could be fixed
with better handling of pattern matching. path-patmat-should-be-pos.scala is a minimization.
x*? is x.type @reach @maybe. This was not recognized before.
We extend the grammar to allow e.g. `Iterator[T]^ @use`.
Convert remaining occurrences in tests to @use
@odersky
Copy link
Contributor Author

odersky commented Oct 9, 2024

Built on the paths PR

@bracevac bracevac assigned bracevac and unassigned bracevac Oct 9, 2024
@bracevac bracevac self-requested a review October 9, 2024 13:51
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