aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
blob: a325fe9f707e0af4ec76a115c4ff063d9d14bc66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package dotty.tools
package dotc
package reporting

import core.Contexts.Context

/**
 * This trait implements `isHidden` so that we avoid reporting non-sensical messages.
 */
trait HideNonSensicalMessages extends Reporter {
  /** Hides non-sensical messages, unless we haven't reported any error yet or
   *  `-Yshow-suppressed-errors` is set.
   */
  override def isHidden(d: Diagnostic)(implicit ctx: Context): Boolean =
    super.isHidden(d) || {
        d.isNonSensical &&
        hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical
        !ctx.settings.YshowSuppressedErrors.value
    }
}