Skip to content
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: Infer more self types automatically #19425

Merged
merged 2 commits into from
Jan 14, 2024
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 11, 2024

Fixes #19398

Clean up the logic how we infer self types, and add a new clause:

If we have an externally extensible class that itself does not have a
declared self type itself and also not in any of its base classes,
assume {cap} as the self type. Previously we would install a capture
set but then check after the fact that that capture set is indeed {cap}.
So it's less verbose to just assume that from the start.

Clean up the logic how we infer self types, and add a new clause:

> If we have an externally extensible class that itself does not have a
declared self types itself and also not in any of its base classes,
assume {cap} as the self type. Previously we would install a capture
set but then check after the fact that that capture set is indeed {cap}.
So it's less verbose to just assume that from the start.
They were causing cycles before. With the new policy these types don't need
to be given explicitly anymore.

I verified that the simple "Option" test now compiles.

Fixes scala#19398
@odersky odersky requested a review from Linyxus January 11, 2024 18:36
@odersky odersky merged commit 9b5815a into scala:main Jan 14, 2024
19 checks passed
@odersky odersky deleted the cc-fix-self branch January 14, 2024 13:30
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
isOneOf(FinalOrSealed) || isClass && !isOneOf(EffectivelyOpenFlags)
isOneOf(FinalOrSealed)
|| isClass && (!isOneOf(EffectivelyOpenFlags)
|| isLocalToCompilationUnit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation suggests this should be an alternative to the line above, but the parentheses make it part of the previous.

@odersky is the indentation just wrong here, or are the parentheses wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks wrong. Non-classes are never sealed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to reformat as part of one of my next PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot load Scala 2 library TASTy with CC annotations
4 participants