Skip to content

Fix #23113: Treat private classes as sealed #23292

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nox213
Copy link
Contributor

@nox213 nox213 commented May 30, 2025

closes: #23113
Currently, child annotations are only attached when the parent class is sealed. This PR extends that behavior to include private classes as well.

@@ -1735,7 +1735,7 @@ object SymDenotations {
c.ensureCompleted()
end completeChildrenIn

if is(Sealed) || isAllOf(JavaEnum) && isClass then
if (is(Sealed) || is(Private) || isAllOf(JavaEnum)) && isClass then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test still passes without this fix, but it seems we should treat private classes as sealed in this case as well.

@sjrd
Copy link
Member

sjrd commented May 30, 2025

That does not seem right to me. Being private certainly implies being effectively sealed. But full sealed is an intentional decision that impacts pattern match exhaustivity checking. There is no spec basis to make that inference, AFAICT.

@nox213
Copy link
Contributor Author

nox213 commented May 30, 2025

#14599
Wasn’t this PR about porting the Scala 2 behavior where private classes are treated like sealed ones for exhaustivity checks in pattern matching?

@Gedochao Gedochao requested a review from sjrd June 2, 2025 06:15
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.

"Unreachable case" is, in fact, reachable
2 participants