-
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.
Allow override protected[C] in companion
When extending C in its companion, allow override protected[C] where C denotes the enclosing companion module of C.
- Loading branch information
Showing
2 changed files
with
36 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
trait Base { | ||
protected[Base] def f: Int | ||
} | ||
object Base { | ||
class Child extends Base { | ||
protected[Base] def f: Int = 42 // ok | ||
def test = f | ||
} | ||
} | ||
|
||
/* | ||
object X { | ||
// restriction in Scala 2 for local companions | ||
// restriction in Scala 3 under -from-tasty | ||
def m: Int = { | ||
trait C { | ||
protected[C] def f: Int | ||
} | ||
object C { | ||
class C2 extends C { | ||
protected[C] def f: Int = 42 // ok | ||
def test = f | ||
} | ||
} | ||
C.C2().test | ||
} | ||
} | ||
*/ |