diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 8923d98ce4ba..31281b413f88 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -407,6 +407,7 @@ object Checking { checkCombination(Final, Sealed) checkCombination(Private, Protected) checkCombination(Abstract, Override) + checkCombination(Private, Override) checkCombination(Lazy, Transparent) checkCombination(Rewrite, Transparent) checkNoConflict(Lazy, ParamAccessor, s"parameter may not be `lazy`") diff --git a/tests/neg/i5052.scala b/tests/neg/i5052.scala new file mode 100644 index 000000000000..f1d62c1251b1 --- /dev/null +++ b/tests/neg/i5052.scala @@ -0,0 +1,13 @@ +class Foo { + protected[this] def foo = 1 + protected def foo2 = 1 + val foo3 = 1 + +} + +class Bar extends Foo { + // illegal combination of modifiers: `private` and `override` + override private[this] def foo = 2 // error + override private[this] def foo2 = 2 // error + override private val foo3 = 2 // error +}