-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
spec private class #9533
Conversation
There is no suggested spec reviewer anymore. @SethTisue can you suggest someone (or maybe reviewing the two sentences is just as fast?) |
spec/05-classes-and-objects.md
Outdated
@@ -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 |
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.
"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)
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.
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.
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.
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.
4ee3ad9
to
fc82328
Compare
[companion class](#object-definitions). | ||
|
||
The `private` modifier is also valid for | ||
[top-level](09-top-level-definitions.html#packagings) templates. |
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.
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].
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.
I suggested not to repeat the semantics here, as they are defined in the linked section.
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.
OK thanks for clarifying. I always forget to click the link. Please don't assume all your readers are so lazy.
private class Foo
wasn't specced anywhere.Aligned the spec here with the implementation, which seems sensible.