Skip to content

Commit 28c73f4

Browse files
authored
Merge pull request #5076 from dotty-staging/fix-5052
Forbid private override modifier combination
2 parents 354611b + 7ed4373 commit 28c73f4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ object Checking {
407407
checkCombination(Final, Sealed)
408408
checkCombination(Private, Protected)
409409
checkCombination(Abstract, Override)
410+
checkCombination(Private, Override)
410411
checkCombination(Lazy, Transparent)
411412
checkCombination(Rewrite, Transparent)
412413
checkNoConflict(Lazy, ParamAccessor, s"parameter may not be `lazy`")

tests/neg/i5052.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Foo {
2+
protected[this] def foo = 1
3+
protected def foo2 = 1
4+
val foo3 = 1
5+
6+
}
7+
8+
class Bar extends Foo {
9+
// illegal combination of modifiers: `private` and `override`
10+
override private[this] def foo = 2 // error
11+
override private[this] def foo2 = 2 // error
12+
override private val foo3 = 2 // error
13+
}

0 commit comments

Comments
 (0)