-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add captureset levels (draft) #18348
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
Conversation
This was overlooked before.
31494b9
to
d4fad8c
Compare
Here's a sketch of the underlying theory (not yet precisely implemented): Let
Define a translation |T|a, |t|a on types and terms as follows:
This translation should be type preserving, i.e. if With that translation, we can enforce scoped capabilities as follows:
Bad usage:
These expand to
The argument of usingFile
This enforcement works without needing the restriction that box/unbox cannot use a root capability. The previous restriction, The scheme also allows the creation of fresh capabilities that get returned:
|
Algorithm draft:
|
There was a corner case in installAfter where - A denotation valid in a single phase got replaced by another one - Immediately after, the symbol's denotation would be forced in a previous phase This somehow landed on a wrong denotation. The problem got apparent when more symbols underwent a Recheck.updateInfoBetween. The flags field installed by a previous update somehow was not recognized anymore. Specifically, the following was observed in order: 1. For a parameter getter (xs in LazyList, file pos-custeom-args/captures/lazylists1.scala) the Private flag was suppressed via transformInfo at phase cc. 2. The denotation of the getter v which was valid in the single phase cc+1 was updated at at cc by updateInfoInBetween in Recheck so that the Private flag was re-asserted in cc+1. 3. Immediately afterwards, the getter's flags was demanded at phase cc. 4. The Private flag was present, even though it should not be. The problem was fixed by demanding the denotation of the getter as part of isntallAfter.
Constrain closure parameters and result from expected type before rechecking the closure's body. This gives more precise types and avoids the spurious duplication of some variables. It also avoids the unmotivated special case that we needed before to make tests pass.
d4fad8c
to
c4aefa1
Compare
Previously, the result of a map could contain duplicates. I verified that with the current code base this could cause problems only for capture checking.
This reduces the chance of information loss in capture set propagation for applications.
- Define a notion of ccNestingLevel, which corresponds to the nesting level of so called "level owners" relative to each other. - The outermost level owner is _root_. - Other level owners are classes that are not staticOwners and methods that are not constructors. - The ccNestingLevel of any symbol is the ccNestingLevel of its closest enclosing level owner, or -1 for NoSymbol. - Capture set variables are created with a level owner. - Capture set variables cannot include elements with higher ccNestingLevels than the variable's owner. - If level-incorrect elements are attempted to be added to a capture set variable, they are instead widened to the underlying capture set.
0635958
to
cb89d50
Compare
cb89d50
to
cd67244
Compare
Superseded by #18463 |
A new scope restriction scheme for capture checking based on levels. The idea is to have a stack of capture roots where inner capture roots are super-captures of outer roots. Refines and supersedes #18348
This is an attempt to implement a new scope restriction scheme for capture checking based on levels.
The idea is to have a stack of capture roots where inner capture roots are super-captures of outer roots.
The draft needs to be refined and justified by theory before it can be merged.