-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve error message for inaccessible types #18406
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
smarter
merged 3 commits into
scala:main
from
dotty-staging:improve-error-message-for-inaccessible-types
Oct 13, 2023
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
-- [E008] Not Found Error: tests/neg/i12573.scala:23:38 ---------------------------------------------------------------- | ||
23 |val w: Value[8] = DFBits(Value[8](8)).getDFType.width // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| value getDFType is not a member of DFBits[(8 : Int)]. | ||
| Extension methods were tried, but the search failed with: | ||
|value getDFType is not a member of DFBits[(8 : Int)]. | ||
|Extension methods were tried, but the search failed with: | ||
| | ||
| method getDFType cannot be accessed as a member of DFType.type from module class i12573$package$. | ||
| Access to protected method getDFType not permitted because enclosing package object i12573$package | ||
| is not a subclass of object DFType where target is defined | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- [E173] Reference Error: tests/neg/not-accessible.scala:8:23 --------------------------------------------------------- | ||
8 | def test(a: A) = a.x // error | ||
| ^^^ | ||
| value x cannot be accessed as a member of (a : foo.A) from class B. | ||
-- [E173] Reference Error: tests/neg/not-accessible.scala:10:23 -------------------------------------------------------- | ||
10 | def test(a: A) = a.x // error | ||
| ^^^ | ||
| value x cannot be accessed as a member of (a : foo.A) from object B. | ||
-- [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 top-level definition in package bar. | ||
-- [E173] Reference Error: tests/neg/not-accessible.scala:5:21 --------------------------------------------------------- | ||
5 | def test(a: A) = a.x // error | ||
| ^^^ | ||
| value x cannot be accessed as a member of (a : foo.A) from top-level definition in package foo. | ||
-- [E173] Reference Error: tests/neg/not-accessible.scala:15:23 -------------------------------------------------------- | ||
15 |def test(a: foo.A) = a.x // error | ||
| ^^^ | ||
| value x cannot be accessed as a member of (a : foo.A) from top-level definition in package <empty>. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package foo: | ||
|
||
class A(private[A] val x: Int) | ||
|
||
def test(a: A) = a.x // error | ||
|
||
class B: | ||
def test(a: A) = a.x // error | ||
object B: | ||
def test(a: A) = a.x // error | ||
|
||
package bar: | ||
def test(a: A) = a.x // error | ||
|
||
def test(a: foo.A) = a.x // error |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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