Skip to content

Commit f6e5bc6

Browse files
committed
Harden checkApply duplicate error detection
Use an explicit `reported` set. The previous logic suppressed some real non-duplicate errors.
1 parent 9105cf3 commit f6e5bc6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/cc/SepCheck.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
477477
| actualCaptures = ${args.map(arg => CaptureSet(captures(arg)))},
478478
| deps = ${deps.toList}""")
479479
val parts = qual :: args
480+
var reported: SimpleIdentitySet[Tree] = SimpleIdentitySet.empty
480481

481482
for arg <- args do
482483
val argPeaks = PeaksPair(
@@ -495,7 +496,9 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
495496
// 1. test argPeaks.actual against previously captured hidden sets
496497
if !argPeaks.actual.sharedWith(currentPeaks.hidden).isEmpty then
497498
val clashing = clashingPart(argPeaks.actual, _.hidden)
498-
if !clashing.isEmpty then sepApplyError(fn, parts, clashing, arg)
499+
if !clashing.isEmpty then
500+
sepApplyError(fn, parts, clashing, arg)
501+
reported += clashing
499502
else assert(!argDeps.isEmpty)
500503

501504
if arg.needsSepCheck then
@@ -505,9 +508,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
505508
if !argPeaks.hidden.sharedWith(currentPeaks.actual).isEmpty then
506509
val clashing = clashingPart(argPeaks.hidden, _.actual)
507510
if !clashing.isEmpty then
508-
if !clashing.needsSepCheck then
509-
// if clashing needs a separation check then we already got an erro
510-
// in (1) at position of clashing. No need to report it twice.
511+
if !reported.contains(clashing) then
511512
//println(i"CLASH $arg / ${argPeaks.formal} vs $clashing / ${peaksOfTree(clashing).actual} / ${captures(clashing).peaks}")
512513
sepApplyError(fn, parts, arg, clashing)
513514
else assert(!argDeps.isEmpty)

0 commit comments

Comments
 (0)