diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index d50f662d7652..9d63c2a0da98 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -278,11 +278,12 @@ object Checking { def checkValidOperator(sym: Symbol)(implicit ctx: Context): Unit = sym.name.toTermName match { case name: SimpleName - if name.exists(isOperatorPart) && - !sym.getAnnotation(defn.AlphaAnnot).isDefined && - !sym.is(Synthetic) && - !name.isConstructorName && - ctx.settings.strict.value => + if name.exists(isOperatorPart) + && !name.isSetterName + && !name.isConstructorName + && !sym.getAnnotation(defn.AlphaAnnot).isDefined + && !sym.is(Synthetic) + && ctx.settings.strict.value => ctx.deprecationWarning( i"$sym has an operator name; it should come with an @alpha annotation", sym.sourcePos) case _ => diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index ecf290c842c1..32087a21ba85 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -57,7 +57,8 @@ class CompilationTests extends ParallelTesting { defaultOptions.and("-nowarn", "-Xfatal-warnings") ), compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40")), - compileFile("tests/pos-special/indent-colons.scala", defaultOptions.and("-Yindent-colons")) + compileFile("tests/pos-special/indent-colons.scala", defaultOptions.and("-Yindent-colons")), + compileFile("tests/pos-special/i7296.scala", defaultOptions.and("-strict", "-deprecation", "-Xfatal-warnings")) ).checkCompile() } diff --git a/tests/pos-special/i7296.scala b/tests/pos-special/i7296.scala new file mode 100644 index 000000000000..aa21e75ff741 --- /dev/null +++ b/tests/pos-special/i7296.scala @@ -0,0 +1,2 @@ +class Foo + private var blah: Double = 0L \ No newline at end of file