-
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.
Constructor companion gets privateWithin (#22627)
Follow-up to #22560 Fixes #22626 When creating a companion for a constructor proxy, the companion is `protected` if the class is. Now it also receives the `privateWithin` boundary of the class, for `protected[p]`.
- Loading branch information
Showing
9 changed files
with
99 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
-- [E173] Reference Error: tests/neg/i18545.scala:13:20 ---------------------------------------------------------------- | ||
13 | def test: IOLocal.IOLocalImpl[Int] = // error | ||
-- [E173] Reference Error: tests/neg/i18545.scala:16:20 ---------------------------------------------------------------- | ||
16 | def test: IOLocal.IOLocalImpl[Int] = // error | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|class IOLocalImpl cannot be accessed as a member of iolib.IOLocal.type from the top-level definitions in package tests. | ||
| private[IOLocal] class IOLocalImpl can only be accessed from object IOLocal in package iolib. | ||
-- [E173] Reference Error: tests/neg/i18545.scala:14:24 ---------------------------------------------------------------- | ||
14 | IOLocal.IOLocalImpl.apply(42) // error | ||
-- [E173] Reference Error: tests/neg/i18545.scala:17:24 ---------------------------------------------------------------- | ||
17 | IOLocal.IOLocalImpl.apply(42) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|method apply cannot be accessed as a member of iolib.IOLocal.IOLocalImpl.type from the top-level definitions in package tests. | ||
| private[IOLocal] method apply can only be accessed from object IOLocal in package iolib. | ||
-- [E050] Type Error: tests/neg/i18545.scala:15:22 --------------------------------------------------------------------- | ||
15 | def test2 = IOLocal.IOLocalImpl(42) // error | ||
-- [E050] Type Error: tests/neg/i18545.scala:18:22 --------------------------------------------------------------------- | ||
18 | def test2 = IOLocal.IOLocalImpl(42) // error | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| object IOLocalImpl in object IOLocal does not take parameters | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E173] Reference Error: tests/neg/i18545.scala:19:22 ---------------------------------------------------------------- | ||
19 | def test3 = IOLocal.AltIOLocalImpl.apply(42) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|object AltIOLocalImpl cannot be accessed as a member of iolib.IOLocal.type from the top-level definitions in package tests. | ||
| private[IOLocal] object AltIOLocalImpl can only be accessed from object IOLocal in package iolib. | ||
-- [E173] Reference Error: tests/neg/i18545.scala:20:22 ---------------------------------------------------------------- | ||
20 | def test4 = IOLocal.AltIOLocalImpl(42) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|object AltIOLocalImpl cannot be accessed as a member of iolib.IOLocal.type from the top-level definitions in package tests. | ||
| private[IOLocal] object AltIOLocalImpl can only be accessed from object IOLocal in package iolib. |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
package i22560: | ||
val alpha = C.D() // error | ||
|
||
class Test extends Enumeration: | ||
val Hearts = Val(27) // error | ||
val Diamonds = Val() // error | ||
|
||
package q: | ||
def f() = p.C(42) // error | ||
def g() = p.D(42) // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
package i22560: | ||
|
||
object C: | ||
protected class D | ||
|
||
class Enumeration: | ||
protected class Val(i: Int): | ||
def this() = this(42) | ||
object Val | ||
|
||
package p: | ||
private[p] class C(i: Int) // companion gets privateWithin of class | ||
private[p] class D(i: Int) // ctor proxy gets privateWithin of class | ||
object D | ||
|
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
package companionless: | ||
|
||
class Test extends Enumeration: | ||
val Hearts = Val(27) | ||
val Diamonds = Val() | ||
|
||
|
||
package companioned: | ||
|
||
class Test extends Enumeration: | ||
val Hearts = Val(27) | ||
val Diamonds = Val() | ||
|
||
package p: | ||
|
||
def f = internal.P(42) |
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,19 @@ | ||
|
||
package companionless: | ||
|
||
class Enumeration: | ||
protected class Val(i: Int): | ||
def this() = this(42) | ||
|
||
package companioned: | ||
|
||
class Enumeration: | ||
protected class Val(i: Int): | ||
def this() = this(42) | ||
protected object Val | ||
|
||
package p: | ||
|
||
package internal: | ||
|
||
protected[p] class P(i : Int) |