Skip to content

Commit 2bdec59

Browse files
authored
Merge pull request #7316 from dotty-staging/fix-#7296
Fix #7296: Don't flag setter names as operator names
2 parents bd9744d + aa50558 commit 2bdec59

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,12 @@ object Checking {
278278
def checkValidOperator(sym: Symbol)(implicit ctx: Context): Unit =
279279
sym.name.toTermName match {
280280
case name: SimpleName
281-
if name.exists(isOperatorPart) &&
282-
!sym.getAnnotation(defn.AlphaAnnot).isDefined &&
283-
!sym.is(Synthetic) &&
284-
!name.isConstructorName &&
285-
ctx.settings.strict.value =>
281+
if name.exists(isOperatorPart)
282+
&& !name.isSetterName
283+
&& !name.isConstructorName
284+
&& !sym.getAnnotation(defn.AlphaAnnot).isDefined
285+
&& !sym.is(Synthetic)
286+
&& ctx.settings.strict.value =>
286287
ctx.deprecationWarning(
287288
i"$sym has an operator name; it should come with an @alpha annotation", sym.sourcePos)
288289
case _ =>

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class CompilationTests extends ParallelTesting {
5757
defaultOptions.and("-nowarn", "-Xfatal-warnings")
5858
),
5959
compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40")),
60-
compileFile("tests/pos-special/indent-colons.scala", defaultOptions.and("-Yindent-colons"))
60+
compileFile("tests/pos-special/indent-colons.scala", defaultOptions.and("-Yindent-colons")),
61+
compileFile("tests/pos-special/i7296.scala", defaultOptions.and("-strict", "-deprecation", "-Xfatal-warnings"))
6162
).checkCompile()
6263
}
6364

tests/pos-special/i7296.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo
2+
private var blah: Double = 0L

0 commit comments

Comments
 (0)