Skip to content

Commit 7707ae9

Browse files
Fix #24886: Only check conflicting defaults for methods that actually conflict
1 parent b53002a commit 7707ae9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,9 +1374,10 @@ trait Checking {
13741374
() // do nothing; we already have reported an error that overloaded variants cannot have default arguments
13751375
else if decl.is(Synthetic) then doubleDefError(other, decl)
13761376
else doubleDefError(decl, other)
1377-
if decl.hasDefaultParams && other.hasDefaultParams then
1378-
report.error(em"two or more overloaded variants of $decl have default arguments", decl.srcPos)
1379-
decl.resetFlag(HasDefaultParams)
1377+
// Check for conflicting default arguments only if they actually conflict
1378+
if decl.hasDefaultParams && other.hasDefaultParams then
1379+
report.error(em"two or more overloaded variants of $decl have default arguments", decl.srcPos)
1380+
decl.resetFlag(HasDefaultParams)
13801381
if !excludeFromDoubleDeclCheck(decl) then
13811382
seen(decl.name) = decl :: seen(decl.name)
13821383

0 commit comments

Comments
 (0)