-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Revise capability hierarchy and fix classifiers #23656
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
Open
odersky
wants to merge
12
commits into
scala:main
Choose a base branch
from
dotty-staging:change-reach
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+913
−455
Conversation
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
We now always give a reason in a TypeMismatch about which capture set inclusion failed.
Include result capabilities unless they are bound in the result.
Now we also report on level and classifier errors when comparing with FreshCaps.
Make reach improvement also dependent on migthSubCapture
- fix tryClassify and trsnaClassifiers for core capabilities - freeze classifications of FreshCaps in constant sets
- two subtraits: SharedCapability and ExclusiveCapability
Pre-type closure bodies with expected result type if expected type is a parametric function. This avoids turning fresh caps in their result type into result caps
For capabilities classified as Shared, assume `cap` instead.
I think this is ready for review now. |
Linyxus
approved these changes
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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.
We now make
Capability
a sealed trait with two subtraits:SharedCapability
andExclusiveCapability
. This forces one to pick one or the other when defining a newCapability
type. Most tests were changed to useSharedCapability
instead ofCapability
. Since classifiers are now much more common than before, this showed up some bugs and anomalies for classifyer handling, which are also addressed in this PR.Details:
captureSetOfInfo
. During experimentation I found that sometimescaptureSetOfInfo
could be cached too early, leading to a locked in universal cap in the info where we would expect to see a fresh cap. On the standard library it did not look like this had a noticeable performance impact.tryClassifyAs
andtransClassifiers
. In particular, we need to distinguishFreshCap
s that can still be classified from ones that cannot. Once aFreshCap
is part of a constant capture set, it gets classified by the type that prefixes the set and that classification cannot be changed anymore. But otherFreshCap
s are created as members of variable sets and then their classification status is open and can be constrained further.cap.rd
as implicitly added capability only for references extendingExclusiveCapability
. Usecap
for the others.We also include now captures in the result type of a function in the
captureSetofInfo
of that function.