-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve error message for inaccessible types #18406
Improve error message for inaccessible types #18406
Conversation
nicolasstucki
commented
Aug 16, 2023
•
edited
Loading
edited
- If accessed from an object:
- If accessed from a package:
1c0165d
to
ee9ab21
Compare
tests/neg/not-accessible.check
Outdated
@@ -9,12 +9,12 @@ | |||
-- [E173] Reference Error: tests/neg/not-accessible.scala:13:23 -------------------------------------------------------- | |||
13 | def test(a: A) = a.x // error | |||
| ^^^ | |||
| value x cannot be accessed as a member of (a : foo.A) from package object not-accessible$package. | |||
| value x cannot be accessed as a member of (a : foo.A) from package object bar. |
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.
That's wrong, the package object bar
is always an object named package
in the package bar
, I think this should say "from a top-level definition in package bar"
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.
Updated
ee9ab21
to
9fcb939
Compare
9fcb939
to
1920336
Compare
tests/neg/i12573.check
Outdated
| method getDFType cannot be accessed as a member of DFType.type from top-level definition in package <empty>. | ||
| Access to protected method getDFType not permitted because enclosing top-level definition in package <empty> | ||
| is not a subclass of object DFType where target is defined |
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.
It should be "from the top-level definitions" since we're talking about the object here, but also "top-level definitions is not a subclass of ..." isn't really meaningful, the explanation could be simplified to just say "Protected method getDFType can only be accessed from object DFType or one of its subclasses" (and the "or one of its subclasses" part could be dropped for objects too)
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.
Changed
5003e87
to
1472b7a
Compare
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, nice!
Backports #18406 to the LTS branch. PR submitted by the release tooling. [skip ci]