@@ -10,23 +10,27 @@ import collection.mutable
10
10
import config .Settings .Setting
11
11
import config .Printers
12
12
import java .lang .System .currentTimeMillis
13
+ import typer .ErrorReporting .DiagnosticString
13
14
14
15
object Reporter {
15
16
16
17
class Diagnostic (msgFn : => String , val pos : SourcePosition , val severity : Severity ) extends Exception {
18
+ import DiagnosticString ._
17
19
private var myMsg : String = null
18
- private var myIsSuppressed : Boolean = false
20
+ private var myIsNonSensical : Boolean = false
19
21
def msg : String = {
20
- if (myMsg == null )
21
- try myMsg = msgFn
22
- catch {
23
- case ex : SuppressedMessage =>
24
- myIsSuppressed = true
25
- myMsg = " <suppressed message> "
22
+ if (myMsg == null ) {
23
+ myMsg = msgFn
24
+ if (myMsg.contains(nonSensicalStartTag)) {
25
+ myIsNonSensical = true
26
+ // myMsg might be composed of several d"..." invocations -> nested nonsensical tags possible
27
+ myMsg = myMsg.replaceAllLiterally(nonSensicalStartTag, " " ).replaceAllLiterally(nonSensicalEndTag, " " )
26
28
}
29
+ }
27
30
myMsg
28
31
}
29
- def isSuppressed = { msg; myIsSuppressed }
32
+ def isNonSensical = { msg; myIsNonSensical }
33
+ def isSuppressed (implicit ctx : Context ): Boolean = ! ctx.settings.YshowSuppressedErrors .value && isNonSensical
30
34
override def toString = s " $severity at $pos: $msg"
31
35
override def getMessage () = msg
32
36
@@ -68,8 +72,6 @@ object Reporter {
68
72
case UncheckedWARNING => ctx.settings.unchecked
69
73
case FeatureWARNING => ctx.settings.feature
70
74
}
71
-
72
- class SuppressedMessage extends Exception
73
75
}
74
76
75
77
import Reporter ._
0 commit comments