@@ -94,7 +94,7 @@ class ConsoleReporter(
94
94
}).show else " "
95
95
96
96
/** Prints the message with the given position indication. */
97
- def printMessageAndPos (msg : Message , pos : SourcePosition , diagnosticLevel : String )(implicit ctx : Context ): Unit = {
97
+ def printMessageAndPos (msg : Message , pos : SourcePosition , diagnosticLevel : String )(implicit ctx : Context ): Boolean = {
98
98
printMessage(posStr(pos, diagnosticLevel, msg))
99
99
if (pos.exists) {
100
100
val (srcBefore, srcAfter, offset) = sourceLines(pos)
@@ -103,6 +103,7 @@ class ConsoleReporter(
103
103
104
104
printMessage((srcBefore ::: marker :: err :: srcAfter).mkString(" \n " ))
105
105
} else printMessage(msg.msg)
106
+ true
106
107
}
107
108
108
109
def printExplanation (m : Message )(implicit ctx : Context ): Unit = {
@@ -114,11 +115,13 @@ class ConsoleReporter(
114
115
}
115
116
116
117
override def doReport (m : MessageContainer )(implicit ctx : Context ): Unit = {
117
- m match {
118
+ val didPrint = m match {
118
119
case m : Error =>
119
- printMessageAndPos(m.contained, m.pos, " Error" )
120
+ val didPrint = printMessageAndPos(m.contained, m.pos, " Error" )
120
121
if (ctx.settings.prompt.value) displayPrompt()
122
+ didPrint
121
123
case m : ConditionalWarning if ! m.enablingOption.value =>
124
+ false
122
125
case m : FeatureWarning =>
123
126
printMessageAndPos(m.contained, m.pos, " Feature Warning" )
124
127
case m : DeprecationWarning =>
@@ -133,9 +136,9 @@ class ConsoleReporter(
133
136
printMessageAndPos(m.contained, m.pos, " Info" )
134
137
}
135
138
136
- if (ctx.shouldExplain(m))
139
+ if (didPrint && ctx.shouldExplain(m))
137
140
printExplanation(m.contained)
138
- else if (m.contained.explanation.nonEmpty)
141
+ else if (didPrint && m.contained.explanation.nonEmpty)
139
142
printMessage(" \n longer explanation available when compiling with `-explain`" )
140
143
}
141
144
0 commit comments