Skip to content

spec private class #9533

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 1 commit into from
Mar 11, 2021
Merged

spec private class #9533

merged 1 commit into from
Mar 11, 2021

Conversation

martijnhoekstra
Copy link
Contributor

private class Foo wasn't specced anywhere.

Aligned the spec here with the implementation, which seems sensible.

@scala-jenkins scala-jenkins added this to the 2.13.6 milestone Mar 5, 2021
@martijnhoekstra martijnhoekstra added the documentation No code change. Only documentation label Mar 5, 2021
@martijnhoekstra
Copy link
Contributor Author

There is no suggested spec reviewer anymore. @SethTisue can you suggest someone (or maybe reviewing the two sentences is just as fast?)

@@ -502,10 +502,11 @@ definition apply to all constituent definitions. The rules governing
the validity and meaning of a modifier are as follows.

### `private`
The `private` modifier can be used with any definition or
declaration in a template. Such members can be accessed only from
The `private` modifier can be used with any template definition or any definition or
Copy link
Member

Choose a reason for hiding this comment

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

"any template" is not accurate, local definitions can't be private. Maybe also say "top-level" here?

scala> def f = { private class C; 0 }
                 ^
       error: illegal start of statement (no modifiers allowed here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe split it up then?

The `private` modifier can be used with any definition or declaration in a
template. Private members of a template can be accessed only from within the
directly enclosing template and its companion module or
[companion class](#object-definitions).

The `private` modifier is also valid for
[top-level](09-top-level-definitions.html#packagings) templates. Private
top-level templates can be accessed only from within the same package.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I think that makes sense. I'd mark it as "Note" and only keep The `private` modifier is also valid for [top-level](09-top-level-definitions.html#packagings) templates instead of repeating it here.

@SethTisue SethTisue merged commit 3540cf2 into scala:2.13.x Mar 11, 2021
[companion class](#object-definitions).

The `private` modifier is also valid for
[top-level](09-top-level-definitions.html#packagings) templates.
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't say what the semantics are; I think you deleted it in an edit.

One might imagine a top-level private class C is private to object C instead of enclosing private[p].

Copy link
Member

Choose a reason for hiding this comment

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

I suggested not to repeat the semantics here, as they are defined in the linked section.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK thanks for clarifying. I always forget to click the link. Please don't assume all your readers are so lazy.

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

Successfully merging this pull request may close these issues.

5 participants