Make Capability types have implied capture sets for new#25346
Merged
Conversation
da5b735 to
f843a47
Compare
0a317d8 to
f8fc07a
Compare
natsukagami
approved these changes
Mar 19, 2026
e200270 to
c7e41e9
Compare
natsukagami
reviewed
Mar 22, 2026
| it must extend `Capability`. This makes sure we add the proper capture set to `new C` | ||
| under separate compilation without having to scan its fields. | ||
|
|
||
| ## Captures of |
natsukagami
approved these changes
Mar 22, 2026
natsukagami
left a comment
Contributor
There was a problem hiding this comment.
Code looks good, I haven't looked at the tests closely.
Why are we dropping Separate?
| * type arguments. Charge deep capture sets of type arguments to non-reserved typevars | ||
| * to the environment. Other generic parents are represented as TypeApplys, where the | ||
| * same check is already done in the TypeApply. | ||
| * 6. Check that capture sets of fields are compatibe with declared extensions of |
Contributor
There was a problem hiding this comment.
Suggested change
| * 6. Check that capture sets of fields are compatibe with declared extensions of | |
| * 6. Check that capture sets of fields are compatible with declared extensions of |
2569407 to
7474a82
Compare
If a class extends a Capability, it will now get a LocalCap on creation. This solves the problem that ```scala class C extends Capability val a = C() val b: C = C() ``` did two different things: `a` was pure but `b` was impure. Now they are both impure.
... where we had use capturesImpliedByFields before.
Since we now always add `any` when creating a capability class, Stateful
should no longer be a capability class. Otherwise, we could not create
an Iterator (which extends Stateful) with capture set such as `{Iterator.this, f}`.
Also: - Do allow mixing an ExclusiveCapability class with stateful as long as it does not have exclusive fields or retains exclusive capabilities otherwise - Drop restriction that a class may not extend both Stateful and SharedCapability - Update doc pages to reflect changes to Stateful and Separate
8ea695c to
a57609c
Compare
Contributor
Author
We don't need it anymore since we add |
a57609c to
d86a7e4
Compare
If C extends Stateful, C means C^{}
If C extends Stateful and SharedCapability, C means C^{any}
If C extends Stateful and ExclusiveCapability, C means C^{any.rd}
d86a7e4 to
b56e2e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a class extends a Capability, it will now get a LocalCap on creation. This
solves the problem that
did two different things:
awas pure butbwas impure. Now they are both impure.Based on #25278
Also, several other new rules around capture sets of
new, outlined on the doc page.