Skip to content

Commit 41060f0

Browse files
committed
Suppress nonsensical follow-on error message
Suppress nonsensical follow-on error message about doubly-defined default getters.
1 parent 1e484e5 commit 41060f0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ trait Checking {
962962
def doubleDefError(decl: Symbol, other: Symbol): Unit =
963963
if (!decl.info.isErroneous && !other.info.isErroneous)
964964
report.error(DoubleDefinition(decl, other, cls), decl.srcPos)
965-
if (decl is Synthetic) doubleDefError(other, decl)
965+
if decl.name.is(DefaultGetterName) && ctx.reporter.errorsReported then
966+
() // do nothing; we already have reported an error that overloaded variants cannot have default arguments
967+
else if (decl is Synthetic) doubleDefError(other, decl)
966968
else doubleDefError(decl, other)
967969
}
968970
if decl.hasDefaultParams && other.hasDefaultParams then

tests/neg/i12245.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package dotty.tools.dotc.core
2+
3+
def round(f: Float, digits: Int = 0): Float = ???
4+
//@scala.annotation.targetName("roundDouble") // does not change anything
5+
def round(d: Double, digits: Int = 0): Double = ??? // error

0 commit comments

Comments
 (0)