@@ -286,10 +286,12 @@ 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 = { Exception = exn; Phase = phase; Severity = severity ; DefaultSeverity = severity }
293295
294296 member this.DebugDisplay () =
295297 sprintf " %s : %s " ( this.Subcategory()) this.Exception.Message
@@ -348,28 +350,14 @@ type PhasedDiagnostic =
348350 | BuildPhase.TypeCheck -> true
349351 | _ -> false
350352
351- type PhasedDiagnosticWithSeverity =
352- {
353- PhasedDiagnostic: PhasedDiagnostic
354- Severity: FSharpDiagnosticSeverity
355- DefaultSeverity: FSharpDiagnosticSeverity
356- }
357-
358- static member Create ( phasedDiagnostic , severity ) =
359- {
360- PhasedDiagnostic = phasedDiagnostic
361- Severity = severity
362- DefaultSeverity = severity
363- }
364-
365353[<AbstractClass>]
366354[<DebuggerDisplay( " {DebugDisplay()}" ) >]
367355type DiagnosticsLogger ( nameForDebugging : string ) =
368356 abstract ErrorCount: int
369357
370358 // The 'Impl' factoring enables a developer to place a breakpoint at the non-Impl
371359 // code just below and get a breakpoint for all error logger implementations.
372- abstract DiagnosticSink: diagnostic : PhasedDiagnosticWithSeverity -> unit
360+ abstract DiagnosticSink: diagnostic : PhasedDiagnostic -> unit
373361
374362 member x.CheckForErrors () = ( x.ErrorCount > 0 )
375363
@@ -401,10 +389,7 @@ type CapturingDiagnosticsLogger(nm, ?eagerFormat) =
401389 let diagnostic =
402390 match eagerFormat with
403391 | None -> diagnostic
404- | Some f ->
405- { diagnostic with
406- PhasedDiagnostic = f diagnostic.PhasedDiagnostic
407- }
392+ | Some f -> f diagnostic
408393
409394 if diagnostic.Severity = FSharpDiagnosticSeverity.Error then
410395 errorCount <- errorCount + 1
@@ -475,13 +460,8 @@ module DiagnosticsLoggerExtensions =
475460 PreserveStackTrace exn
476461 raise exn
477462 | _ ->
478- let phasedDiagnostic =
479- PhasedDiagnostic.Create( exn, DiagnosticsThreadStatics.BuildPhase)
480-
481- let diagnosticWithSeverity =
482- PhasedDiagnosticWithSeverity.Create( phasedDiagnostic, severity)
483-
484- x.DiagnosticSink( diagnosticWithSeverity)
463+ let diagnostic = PhasedDiagnostic.Create( exn, DiagnosticsThreadStatics.BuildPhase, severity)
464+ x.DiagnosticSink( diagnostic)
485465
486466 member x.ErrorR exn =
487467 x.EmitDiagnostic( exn, FSharpDiagnosticSeverity.Error)
@@ -497,10 +477,7 @@ module DiagnosticsLoggerExtensions =
497477 raise ( ReportedError( Some exn))
498478
499479 member x.SimulateError ( diagnostic ) =
500- let diagnosticWithSeverity =
501- PhasedDiagnosticWithSeverity.Create( diagnostic, FSharpDiagnosticSeverity.Error)
502-
503- x.DiagnosticSink( diagnosticWithSeverity)
480+ x.DiagnosticSink( diagnostic)
504481 raise ( ReportedError( Some diagnostic.Exception))
505482
506483 member x.ErrorRecovery ( exn : exn ) ( m : range ) =
@@ -613,12 +590,6 @@ let simulateError diagnostic =
613590let diagnosticSink diagnostic =
614591 DiagnosticsThreadStatics.DiagnosticsLogger.DiagnosticSink( diagnostic)
615592
616- let errorSink diagnostic =
617- diagnosticSink ( PhasedDiagnosticWithSeverity.Create( diagnostic, FSharpDiagnosticSeverity.Error))
618-
619- let warnSink diagnostic =
620- diagnosticSink ( PhasedDiagnosticWithSeverity.Create( diagnostic, FSharpDiagnosticSeverity.Warning))
621-
622593let errorRecovery exn m =
623594 DiagnosticsThreadStatics.DiagnosticsLogger.ErrorRecovery exn m
624595
0 commit comments