diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index fe2cc3bb887a..edd1016d3246 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -962,7 +962,9 @@ trait Checking { def doubleDefError(decl: Symbol, other: Symbol): Unit = if (!decl.info.isErroneous && !other.info.isErroneous) report.error(DoubleDefinition(decl, other, cls), decl.srcPos) - if (decl is Synthetic) doubleDefError(other, decl) + if decl.name.is(DefaultGetterName) && ctx.reporter.errorsReported then + () // do nothing; we already have reported an error that overloaded variants cannot have default arguments + else if (decl is Synthetic) doubleDefError(other, decl) else doubleDefError(decl, other) } if decl.hasDefaultParams && other.hasDefaultParams then diff --git a/tests/neg/i12245.scala b/tests/neg/i12245.scala new file mode 100644 index 000000000000..219f73f0702c --- /dev/null +++ b/tests/neg/i12245.scala @@ -0,0 +1,5 @@ +package dotty.tools.dotc.core + +def round(f: Float, digits: Int = 0): Float = ??? +//@scala.annotation.targetName("roundDouble") // does not change anything +def round(d: Double, digits: Int = 0): Double = ??? // error