Skip to content

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 scheme.
  • Make sure @use appears only in covariant positions of parameters, nowhere else.
  • 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
The new encoding wraps such capabilities with @use instead of relying on a
@ReachUnderUse annotation. Advantage: This can generalize to capture set variables
under @use.
@lrytz
Copy link
Member

lrytz commented Oct 11, 2024

Good luck for https://github.com/unbox, bad luck for https://github.com/use (or their inboxes 😉). I hope no language or framework author ever thinks @lrytz would be a nice annotation.

@tgodzik
Copy link
Contributor

tgodzik commented Oct 11, 2024

Good luck for https://github.com/unbox, bad luck for https://github.com/use (or their inboxes 😉). I hope no language or framework author ever thinks @lrytz would be a nice annotation.

Tempting...

As a side note you can always do @use or @unbox which will avoid the unnecessary mentions

Edit: Ach I see that it's already used in the description also, it's just way to easy to forget.

@odersky
Copy link
Contributor Author

odersky commented Oct 11, 2024

OK, will backquote things from now on.

@bracevac
Copy link
Contributor

I hope no language or framework author ever thinks @lrytz would be a nice annotation.

New experimental polymorphic effect system confirmed.

@odersky odersky marked this pull request as draft October 30, 2024 14:47
@odersky
Copy link
Contributor Author

odersky commented Nov 4, 2024

Closing since I am no longer hopeful that this approach will work out.

@odersky odersky closed this Nov 6, 2024
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.

5 participants