-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Changes in CC around classes, constructors, this #23874
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
Merged
Merged
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
These problems were discovered once we started recording uses of this references. The recording is not yet part of this commit because it requires downstream bugfixes in the compiler.
These fell through the cracks before since we only considered named outer refs. But inner classes can have outer this references check needd to be tracked in use sets.
Previously there was a boundary condition where this could be the case for outermost classes.
A constructor should never capture `this`, the object it constructs.
Was shockingly missing before.
- Charge the use set of the initializer to the class constructor - Charge the declared capture set to the class
5ba4cf7
to
b7387d1
Compare
noti0na1
approved these changes
Sep 7, 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!
odersky
added a commit
that referenced
this pull request
Sep 8, 2025
- Propagate expected type into blocks The level checking should do the proper avoidance so that local symbols would not leak into type variables of the expected type. - Don't automatically add a FreshCap owner to its hidden set - Don't use span capture sets for function types as the underlying set Based on #23874
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.
This PR started with a shocking discovery. We actually did not record this-references in use sets. Once this was fixed, some tests failed and the stdlib build broke with 20 errors. 18 of these were oversights that were not caught before and were easily fixed. 2 of them pointed to further capture checking problems. This caused a sequence of successive fixes until everything compiled again and all the tests made sense.
The order in the commits here is a bit different: We first apply the fixes to the stdlib and the compiler and then start recording uses of this. This is so that we don't have a failing build in intermediate steps.