@@ -286,10 +286,18 @@ type PhasedDiagnostic =
286286 {
287287 Exception: exn
288288 Phase: BuildPhase
289+ Severity: FSharpDiagnosticSeverity
290+ DefaultSeverity: FSharpDiagnosticSeverity
289291 }
290292
291293 /// Construct a phased error
292- static member Create ( exn : exn , phase : BuildPhase ) : PhasedDiagnostic = { Exception = exn; Phase = phase }
294+ static member Create ( exn : exn , phase : BuildPhase , severity : FSharpDiagnosticSeverity ) : PhasedDiagnostic =
295+ {
296+ Exception = exn
297+ Phase = phase
298+ Severity = severity
299+ DefaultSeverity = severity
300+ }
293301
294302 member this.DebugDisplay () =
295303 sprintf " %s : %s " ( this.Subcategory()) this.Exception.Message
@@ -355,7 +363,7 @@ type DiagnosticsLogger(nameForDebugging: string) =
355363
356364 // The 'Impl' factoring enables a developer to place a breakpoint at the non-Impl
357365 // code just below and get a breakpoint for all error logger implementations.
358- abstract DiagnosticSink: diagnostic : PhasedDiagnostic * severity : FSharpDiagnosticSeverity -> unit
366+ abstract DiagnosticSink: diagnostic : PhasedDiagnostic -> unit
359367
360368 member x.CheckForErrors () = ( x.ErrorCount > 0 )
361369
@@ -367,14 +375,14 @@ type DiagnosticsLogger(nameForDebugging: string) =
367375
368376let DiscardErrorsLogger =
369377 { new DiagnosticsLogger( " DiscardErrorsLogger" ) with
370- member _.DiagnosticSink ( diagnostic , severity ) = ()
378+ member _.DiagnosticSink ( diagnostic ) = ()
371379 member _.ErrorCount = 0
372380 }
373381
374382let AssertFalseDiagnosticsLogger =
375383 { new DiagnosticsLogger( " AssertFalseDiagnosticsLogger" ) with
376384 // TODO: reenable these asserts in the compiler service
377- member _.DiagnosticSink ( diagnostic , severity ) = (* assert false; *) ()
385+ member _.DiagnosticSink ( diagnostic ) = (* assert false; *) ()
378386 member _.ErrorCount = (* assert false; *) 0
379387 }
380388
@@ -383,16 +391,16 @@ type CapturingDiagnosticsLogger(nm, ?eagerFormat) =
383391 let mutable errorCount = 0
384392 let diagnostics = ResizeArray()
385393
386- override _.DiagnosticSink ( diagnostic , severity ) =
394+ override _.DiagnosticSink ( diagnostic ) =
387395 let diagnostic =
388396 match eagerFormat with
389397 | None -> diagnostic
390398 | Some f -> f diagnostic
391399
392- if severity = FSharpDiagnosticSeverity.Error then
400+ if diagnostic.Severity = FSharpDiagnosticSeverity.Error then
393401 errorCount <- errorCount + 1
394402
395- diagnostics.Add( diagnostic, severity )
403+ diagnostics.Add( diagnostic)
396404
397405 override _.ErrorCount = errorCount
398406
@@ -457,7 +465,7 @@ module DiagnosticsLoggerExtensions =
457465 | ReportedError _ ->
458466 PreserveStackTrace exn
459467 raise exn
460- | _ -> x.DiagnosticSink( PhasedDiagnostic.Create( exn, DiagnosticsThreadStatics.BuildPhase) , severity)
468+ | _ -> x.DiagnosticSink( PhasedDiagnostic.Create( exn, DiagnosticsThreadStatics.BuildPhase, severity) )
461469
462470 member x.ErrorR exn =
463471 x.EmitDiagnostic( exn, FSharpDiagnosticSeverity.Error)
@@ -472,8 +480,8 @@ module DiagnosticsLoggerExtensions =
472480 x.ErrorR exn
473481 raise ( ReportedError( Some exn))
474482
475- member x.SimulateError diagnostic =
476- x.DiagnosticSink( diagnostic, FSharpDiagnosticSeverity.Error )
483+ member x.SimulateError ( diagnostic ) =
484+ x.DiagnosticSink( diagnostic)
477485 raise ( ReportedError( Some diagnostic.Exception))
478486
479487 member x.ErrorRecovery ( exn : exn ) ( m : range ) =
@@ -580,17 +588,11 @@ let error exn =
580588 DiagnosticsThreadStatics.DiagnosticsLogger.Error exn
581589
582590/// Simulates an error. For test purposes only.
583- let simulateError ( diagnostic : PhasedDiagnostic ) =
584- DiagnosticsThreadStatics.DiagnosticsLogger.SimulateError diagnostic
585-
586- let diagnosticSink ( diagnostic , severity ) =
587- DiagnosticsThreadStatics.DiagnosticsLogger.DiagnosticSink( diagnostic, severity)
588-
589- let errorSink diagnostic =
590- diagnosticSink ( diagnostic, FSharpDiagnosticSeverity.Error)
591+ let simulateError diagnostic =
592+ DiagnosticsThreadStatics.DiagnosticsLogger.SimulateError( diagnostic)
591593
592- let warnSink diagnostic =
593- diagnosticSink ( diagnostic, FSharpDiagnosticSeverity.Warning )
594+ let diagnosticSink diagnostic =
595+ DiagnosticsThreadStatics.DiagnosticsLogger.DiagnosticSink ( diagnostic)
594596
595597let errorRecovery exn m =
596598 DiagnosticsThreadStatics.DiagnosticsLogger.ErrorRecovery exn m
@@ -623,7 +625,7 @@ let suppressErrorReporting f =
623625 try
624626 let diagnosticsLogger =
625627 { new DiagnosticsLogger( " suppressErrorReporting" ) with
626- member _.DiagnosticSink ( _phasedError , _isError ) = ()
628+ member _.DiagnosticSink ( _diagnostic ) = ()
627629 member _.ErrorCount = 0
628630 }
629631
0 commit comments