File tree 3 files changed +12
-3
lines changed 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import core._
5
5
6
6
import Contexts ._ , Texts ._ , Decorators ._
7
7
import config .Config .summarizeDepth
8
+ import scala .util .control .NonFatal
8
9
9
10
trait Showable extends Any {
10
11
@@ -20,7 +21,11 @@ trait Showable extends Any {
20
21
def fallbackToText (printer : Printer ): Text = toString
21
22
22
23
/** The string representation of this showable element. */
23
- def show (implicit ctx : Context ): String = toText(ctx.printer).show
24
+ def show (implicit ctx : Context ): String =
25
+ try toText(ctx.printer).show
26
+ catch {
27
+ case NonFatal (ex) => s " [cannot display due to $ex, raw string = $toString] "
28
+ }
24
29
25
30
/** The summarized string representation of this showable element.
26
31
* Recursion depth is limited to some smallish value. Default is
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import config.Settings.Setting
11
11
import config .Printers
12
12
import java .lang .System .currentTimeMillis
13
13
import typer .ErrorReporting .DiagnosticString
14
+ import typer .Mode
14
15
15
16
object Reporter {
16
17
@@ -215,7 +216,7 @@ abstract class Reporter {
215
216
}
216
217
217
218
def report (d : Diagnostic )(implicit ctx : Context ): Unit = if (! isHidden(d)) {
218
- doReport(d)
219
+ doReport(d)(ctx.addMode( Mode . Printing ))
219
220
d match {
220
221
case d : ConditionalWarning if ! d.enablingOption.value => unreportedWarnings(d.enablingOption.name) += 1
221
222
case d : Warning => warningCount += 1
@@ -248,7 +249,7 @@ abstract class Reporter {
248
249
}
249
250
250
251
/** Should this diagnostic not be reported at all? */
251
- def isHidden (d : Diagnostic )(implicit ctx : Context ): Boolean = false
252
+ def isHidden (d : Diagnostic )(implicit ctx : Context ): Boolean = ctx.mode.is( Mode . Printing )
252
253
253
254
/** Does this reporter contain not yet reported errors or warnings? */
254
255
def hasPending : Boolean = false
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ object Mode {
63
63
*/
64
64
val AllowDependentFunctions = newMode(9 , " AllowDependentFunctions" )
65
65
66
+ /** We are currently printing something: avoid to produce more logs about
67
+ * the printing
68
+ */
66
69
val Printing = newMode(10 , " Printing" )
67
70
68
71
val PatternOrType = Pattern | Type
You can’t perform that action at this time.
0 commit comments