Skip to content
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

Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Aug 16, 2023

  • If accessed from an object:
- from module class B$
+ from object B
  • If accessed from a package:
- from module class <filename>$package$
+ from top-level definition in package foo

@nicolasstucki nicolasstucki force-pushed the improve-error-message-for-inaccessible-types branch 6 times, most recently from 1c0165d to ee9ab21 Compare August 17, 2023 09:18
@nicolasstucki nicolasstucki self-assigned this Aug 17, 2023
@nicolasstucki nicolasstucki marked this pull request as ready for review August 17, 2023 11:22
@nicolasstucki nicolasstucki removed their assignment Aug 17, 2023
@@ -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.
Copy link
Member

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@smarter smarter assigned nicolasstucki and unassigned smarter Aug 17, 2023
@nicolasstucki nicolasstucki force-pushed the improve-error-message-for-inaccessible-types branch from ee9ab21 to 9fcb939 Compare August 17, 2023 16:02
@nicolasstucki nicolasstucki force-pushed the improve-error-message-for-inaccessible-types branch from 9fcb939 to 1920336 Compare September 19, 2023 12:52
Comment on lines 7 to 9
| 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
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@nicolasstucki nicolasstucki force-pushed the improve-error-message-for-inaccessible-types branch from 5003e87 to 1472b7a Compare October 13, 2023 08:22
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@smarter smarter merged commit 231ca72 into scala:main Oct 13, 2023
18 checks passed
@smarter smarter deleted the improve-error-message-for-inaccessible-types branch October 13, 2023 11:18
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
WojciechMazur added a commit that referenced this pull request Jun 22, 2024
Backports #18406 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants