-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CC: Drop special handling in recheckApplication #21659
Closed
Closed
Conversation
This file contains 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
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.
In recheckApplication we implemented a rule that computed the capture set of an application `f(a)` by being the "better" of either the capture set of `f` union capture set of `a` or the capture set of the result type of `f(a)`. This relies on capture monotinicity, which we try to get away from. Also, it's semantically dubious if the type of the argument `a` is a type variable that can be instantiated to a capturing type as in the following example: ```scala trait Iterator[+A] ... def flatMap[B](f: A => IterableOnce[B]^): Iterator[B]^{this, f} ``` Here, we account for every capability in `IterableOnce[B]^` already in `f`. But those capabilities could also come from `A` if `A` is instantiated in the actual function argument to a capturing type. There was extensive breakage once the special handling was dropped. One example is the `flatMap` definition above. We leave that as a potential soundness hold for now, but the right way to fix `flatMap` would be by adding a capture set variable: ```scala def flatMap[B, C^](f: A => IterableOnce[B]^{C^}): Iterator[B]^{this, f, C^} ``` The problem is that this currently cannot be done in a way that allows flatMap to be called as before, passing a single type argument for `B`. We'd have to change the system to either allow curried type parameters or optional type parameters for capture sets. Another issue is that now more reach capabilities are registered as used by the enclosing method. An example is lazylist-exceptions.scala, which has been moved to pending. Here, the use is spurious because it happens inside an anonymous class creation on the right hand side of the method. With refined use checking, the use would not propagate to the method, so the reach capability should not be leaking. But to get there we need to implement refined use checking first.
Close as the changes have been included in #21445. |
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.
Based on #21445
In recheckApplication we implemented a rule that computed the capture set of an
application
f(a)
by being the "better" of either the capture set off
unioncapture set of
a
or the capture set of the result type off(a)
. This relieson capture monotonicity, which we try to get away from. Also, it's semantically
dubious if the type of the argument
a
is a type variable that can be instantiatedto a capturing type as in the following example:
Here, we account for every capability in
IterableOnce[B]^
already inf
. Butthose capabilities could also come from
A
ifA
is instantiated in theactual function argument to a capturing type.
There was extensive breakage once the special handling was dropped. One example is
the
flatMap
definition above. We leave that as a potential soundness hold for now,but the right way to fix
flatMap
would be by adding a capture set variable:The problem is that this currently cannot be done in a way that allows flatMap to be called
as before, passing a single type argument for
B
. We'd have to change the system to eitherallow curried type parameters or optional type parameters for capture sets.
Another issue is that now more reach capabilities are registered as used by the enclosing method.
An example is lazylist-exceptions.scala, which has been moved to pending. Here, the use is spurious
because it happens inside an anonymous class creation on the right hand side of the method.
With refined use checking, the use would not propagate to the method, so the reach capability should
not be leaking. But to get there we need to implement refined use checking first.