Skip to content

Backport "Separation checking for product types" to 3.7.0 #22964

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

Closed
wants to merge 93 commits into from

Conversation

WojciechMazur
Copy link
Contributor

Backports #22539 to the 3.7.0-RC2.

PR submitted by the release tooling.

odersky and others added 30 commits April 10, 2025 14:43
When printing a type `C^` where `C` extends `Capability`, don't show the `^`.
This is overridden under -Yprint-debug.

[Cherry-picked 103ef96]
 - Add Mutable trait and mut modifier.
 - Add dedicated tests `isMutableVar` and `isMutableVarOrAccessor`
   so that update methods can share the same flag `Mutable` with mutable vars.
 - Disallow update methods overriding normal methods
 - Disallow update methods which are not members of classes extending Mutable
 - Add design document from papers repo to docs/internals
 - Add readOnly capabilities
 - Implement raeadOnly access
 - Check that update methods are only called on references with exclusive capture sets.
 - Use cap.rd as default capture set of Capability subtypes
 - Make Mutable a Capability, this means Mutable class references get {cap.rd} as
   default capture set.
 - Use {cap} as captu

[Cherry-picked 748f4a6]
….toCap

If existentials are mapped to fresh, it matters where they are opened. Pure or not
arguments don't have anything to do with that.

[Cherry-picked e4cc265]
These are represented as Fresh.Cap(hidden) where hidden is the set of
capabilities subsumed by a fresh. The underlying representation is as
an annotated type `T @annotation.internal.freshCapability`.

Require -source `3.7` for caps to be converted to Fresh.Cap

Also:

 - Refacture and document CaputureSet
 - Make SimpleIdentitySets showable
 - Refactor VarState
    - Drop Frozen enum
    - Make VarState subclasses inner classes of companion object
    - Rename them
    - Give implicit parameter VarState of subCapture method a default value
 - Fix printing of capturesets containing cap and some other capability
 - Revise handing of @uncheckedAnnotation

[Cherry-picked ad11819][modified]
Check separation from source 3.7 on.

We currently only check applications, other areas of separation checking
are still to be implemented.

[Cherry-picked 4c8a50f]
Check that a capability that gets hidden in the (result-)type of some
definition is not used afterwards in the same or a nested scope.

[Cherry-picked b0c9b3d]
When checking whether two items overlap we should always check their deep capture sets.
Buried aliases should count as well.

[Cherry-picked 190aaca]
This is necessary since capability sets are IdentitySets.

[Cherry-picked 67d42bd]
TODO:

 - check that only @consume parameters flow to @consume parameters

[Cherry-picked 3adf4b0]
Downgrade to -source 3.6 to turn it off.

[Cherry-picked 52dc9b4]
Allow them only in @consume methods

[Cherry-picked 66fc880]
Also: Fixes to computations of overlapWith and -- on Refs that take
account of pathss, where shorter paths cover deeper ones.

[Cherry-picked 821e17a]
[Cherry-picked 2d37938]
This partially reverts commit 7b3d3f4.
It looks like this fixes the problems we had with CI timeouts as well.

[Cherry-picked 367f66c]
hamzaremmal and others added 25 commits April 10, 2025 14:44
Not allowing whitespace clashes with the rules for leading infix operators. For instance,
the following does not work, since `->` is not recognized as a leading infix operator.

```scala
   A
   ->{x} B
```

Also: Print existential capture set id under -uniqids

[Cherry-picked 4c53fd1]
Also, implement infrastructure to add a note to a type mismatch when a failure
to subsume occurs.

[Cherry-picked 58baf53]
Allows some simplifications in the zoo of classification methods.

[Cherry-picked 33ef293]
Allows some simplifications in the zoo of classification methods.

[Cherry-picked 12047d8]
[Cherry-picked f7484ce]
Exceptions are bracketed in `withCapAsRoot` calls.

[Cherry-picked d27f2bb]
TODO: Check that the new error in box-adapt-contra makes sense
TODO: error messages need to be improved

[Cherry-picked ec8d119]
 1. Strip readonly modifier before checking o=for overlaps
 2. Don't reset consume to empty before entering defs

[Cherry-picked d89138a]
I believe the timeout was simply that we have to many pos tests, so theior compilation takes more than the
limit of 20 minutes. Testing this hypothesis by moving pos-custumargs/captures tests into a separate
top-level test posCC

[Cherry-picked a6f1ab2]
Deduct explicit refs of actual as opposed to formal argument type.

[Cherry-picked d2e276c]
Move extension methods to SepChecks object, drop unused ones.

[Cherry-picked f547582]
 - Make it peak-based instead of footprint-based
 - Don't flag rd/rd conflicts between consumed and re-used

[Cherry-picked ee60b21]
Avoid globally visible vars in CCState. Make sure notes don't leak from one test to another.

[Cherry-picked dc0dd7f]
Intersections used the heuristic mightAccountFor instead of the precise accountsFor. Thsi
can lead to a loss of precision and (if unchecked afterwards) also soundness. The fix caused
some tests to fail, which involved tracked parameters.

We now deal with tracked parameters in the same way as parameters that carry a @refineOverride annotation.

[Cherry-picked 23cb1f3]
[Cherry-picked 48a52a2]
@WojciechMazur
Copy link
Contributor Author

This backport was required by multiple conflicts occurring while backporting relatively small #22849

However, based on the size of changes (in this and 2 other PR) we'd prefer to not backport it at the last moment

64 files changed, 3866 insertions(+), 1500 deletions(-)  // excluding tests
232 files changed, 6362 insertions(+), 2010 deletions(-) // including

@natsukagami @odersky Do you think it would be possible to create an alternative variant for 3.7.0 including only required stabilisation changes without a large refactor? Preferably only having required changes from #22849 and #22956
It feels a bit risky to introduce such big change in such late moment

@odersky
Copy link
Contributor

odersky commented Apr 10, 2025

I agree, this PR should not be backported, the change set is too large. We intentionally waited until after the 3.7 cutoff to merge it. So yes, we need to extract just #22849 and #22956.

@natsukagami
Copy link
Contributor

natsukagami commented Apr 10, 2025

I'll extract the two PRs by tonight.

EDIT see #22967

@WojciechMazur WojciechMazur deleted the backport-release-3.7.0-22539 branch April 11, 2025 14:42
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.

4 participants