-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explain accessible scope of private members in error message
Fixes #18686
- Loading branch information
1 parent
8aec15b
commit 6c1fce0
Showing
13 changed files
with
135 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,13 +1,30 @@ | ||
-- [E173] Reference Error: tests/neg/i18686.scala:9:16 ----------------------------------------------------------------- | ||
9 | println(Foo.Bar1) // error | ||
| ^^^^^^^^ | ||
| value Bar1 cannot be accessed as a member of Foo.type from object Main. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:10:16 ---------------------------------------------------------------- | ||
10 | println(Foo.Bar2) // error | ||
-- [E173] Reference Error: tests/neg/i18686.scala:13:16 ---------------------------------------------------------------- | ||
13 | println(Foo.Bar1) // error | ||
| ^^^^^^^^ | ||
| value Bar1 cannot be accessed as a member of Foo.type from object Main. | ||
| private value Bar1 can only be accessed from object Foo. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:14:16 ---------------------------------------------------------------- | ||
14 | println(Foo.Bar2) // error | ||
| ^^^^^^^^ | ||
| value Bar2 cannot be accessed as a member of Foo.type from object Main. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:11:16 ---------------------------------------------------------------- | ||
11 | println(Foo.Bar3) // error | ||
| private[Foo] value Bar2 can only be accessed from object Foo. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:15:16 ---------------------------------------------------------------- | ||
15 | println(Foo.Bar3) // error | ||
| ^^^^^^^^ | ||
| value Bar3 cannot be accessed as a member of Foo.type from object Main. | ||
| Protected value Bar3 can only be accessed from object Foo. | ||
| protected value Bar3 can only be accessed from object Foo. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:16:16 ---------------------------------------------------------------- | ||
16 | println(Foo.Bar4) // error | ||
| ^^^^^^^^ | ||
| value Bar4 cannot be accessed as a member of Foo.type from object Main. | ||
| protected[Foo] value Bar4 can only be accessed from object Foo. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:17:20 ---------------------------------------------------------------- | ||
17 | println(Foo.Baz.Bar5) // error | ||
| ^^^^^^^^^^^^ | ||
| value Bar5 cannot be accessed as a member of Foo.Baz.type from object Main. | ||
| private[Foo] value Bar5 can only be accessed from object Foo. | ||
-- [E173] Reference Error: tests/neg/i18686.scala:18:20 ---------------------------------------------------------------- | ||
18 | println(Foo.Baz.Bar6) // error | ||
| ^^^^^^^^^^^^ | ||
| value Bar6 cannot be accessed as a member of Foo.Baz.type from object Main. | ||
| protected[Foo] value Bar6 can only be accessed from object Foo. |
This file contains 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,13 +1,20 @@ | ||
object Foo: | ||
private val Bar1: Int = 3 | ||
private[Foo] val Bar2: Int = 3 | ||
private val Bar1: Int = 1 | ||
private[Foo] val Bar2: Int = 2 | ||
protected val Bar3: Int = 3 | ||
protected[Foo] val Bar4: Int = 5 | ||
object Baz: | ||
private[Foo] val Bar5: Int = 5 | ||
protected[Foo] val Bar6: Int = 6 | ||
end Foo | ||
|
||
object Main: | ||
def main(args: Array[String]): Unit = | ||
println(Foo.Bar1) // error | ||
println(Foo.Bar2) // error | ||
println(Foo.Bar3) // error | ||
println(Foo.Bar4) // error | ||
println(Foo.Baz.Bar5) // error | ||
println(Foo.Baz.Bar6) // error | ||
end main | ||
end Main |
This file contains 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,28 @@ | ||
-- [E173] Reference Error: tests/neg/i18686b.scala:15:16 --------------------------------------------------------------- | ||
15 | println(foo.Bar1) // error | ||
| ^^^^^^^^ | ||
| value Bar1 cannot be accessed as a member of Foo from object Main. | ||
| private value Bar1 can only be accessed from class Foo. | ||
-- [E173] Reference Error: tests/neg/i18686b.scala:16:16 --------------------------------------------------------------- | ||
16 | println(foo.Bar2) // error | ||
| ^^^^^^^^ | ||
| value Bar2 cannot be accessed as a member of Foo from object Main. | ||
| private[Foo] value Bar2 can only be accessed from class Foo. | ||
-- [E173] Reference Error: tests/neg/i18686b.scala:17:16 --------------------------------------------------------------- | ||
17 | println(foo.Bar3) // error | ||
| ^^^^^^^^ | ||
| value Bar3 cannot be accessed as a member of Foo from object Main. | ||
| protected value Bar3 can only be accessed from class Foo or one of its subclasses. | ||
-- [E173] Reference Error: tests/neg/i18686b.scala:18:16 --------------------------------------------------------------- | ||
18 | println(foo.Bar4) // error | ||
| ^^^^^^^^ | ||
| value Bar4 cannot be accessed as a member of Foo from object Main. | ||
| protected[Foo] value Bar4 can only be accessed from class Foo or one of its subclasses. | ||
-- [E008] Not Found Error: tests/neg/i18686b.scala:19:20 --------------------------------------------------------------- | ||
19 | println(foo.Baz.Bar5) // error | ||
| ^^^^^^^^^^^^ | ||
| value Bar5 is not a member of object Foo#Baz | ||
-- [E008] Not Found Error: tests/neg/i18686b.scala:20:20 --------------------------------------------------------------- | ||
20 | println(foo.Baz.Bar6) // error | ||
| ^^^^^^^^^^^^ | ||
| value Bar6 is not a member of object Foo#Baz |
This file contains 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,22 @@ | ||
class Foo: | ||
private val Bar1: Int = 1 | ||
private[Foo] val Bar2: Int = 2 | ||
protected val Bar3: Int = 3 | ||
protected[Foo] val Bar4: Int = 5 | ||
class Baz: | ||
private[Foo] val Bar5: Int = 5 | ||
protected[Foo] val Bar6: Int = 6 | ||
end Foo | ||
|
||
def foo = new Foo | ||
|
||
object Main: | ||
def main(args: Array[String]): Unit = | ||
println(foo.Bar1) // error | ||
println(foo.Bar2) // error | ||
println(foo.Bar3) // error | ||
println(foo.Bar4) // error | ||
println(foo.Baz.Bar5) // error | ||
println(foo.Baz.Bar6) // error | ||
end main | ||
end Main |
This file contains 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,8 @@ | ||
-- [E173] Reference Error: tests/neg/i18686c.scala:8:6 ----------------------------------------------------------------- | ||
8 | foo.foo // error | ||
| ^^^^^^^ | ||
|method foo cannot be accessed as a member of (foo² : Bar.Foo) from the top-level definitions in package <empty>. | ||
| protected[Bar] method foo can only be accessed from object Bar, or class Foo in object Bar or one of its subclasses. | ||
| | ||
|where: foo is a method in class Foo | ||
| foo² is a parameter in method test |
This file contains 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,8 @@ | ||
object Bar: | ||
class Foo: | ||
protected[Bar] def foo = 23 | ||
class Qux extends Foo: | ||
val qux = foo | ||
|
||
def test(foo: Bar.Foo) = | ||
foo.foo // error |
This file contains 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 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