@@ -24,6 +24,7 @@ open FSharp.Compiler.ConstraintSolver
2424open FSharp.Compiler .DiagnosticMessage
2525open FSharp.Compiler .Diagnostics
2626open FSharp.Compiler .DiagnosticsLogger
27+ open FSharp.Compiler .Features
2728open FSharp.Compiler .Infos
2829open FSharp.Compiler .IO
2930open FSharp.Compiler .Lexhelp
@@ -2299,17 +2300,12 @@ type PhasedDiagnostic with
22992300// Scoped #nowarn pragmas
23002301
23012302/// Build an DiagnosticsLogger that delegates to another DiagnosticsLogger but filters warnings turned off by the given pragma declarations
2302- //
2303- // NOTE: we allow a flag to turn of strict file checking. This is because file names sometimes don't match due to use of
2304- // #line directives, e.g. for pars.fs/pars.fsy. In this case we just test by line number - in most cases this is sufficient
2305- // because we install a filtering error handler on a file-by-file basis for parsing and type-checking.
2306- // However this is indicative of a more systematic problem where source-line
2307- // sensitive operations (lexfilter and warning filtering) do not always
2308- // interact well with #line directives.
23092303type DiagnosticsLoggerFilteringByScopedPragmas
2310- ( checkFile , scopedPragmas, diagnosticOptions: FSharpDiagnosticOptions, diagnosticsLogger: DiagnosticsLogger) =
2304+ ( langVersion : LanguageVersion , scopedPragmas, diagnosticOptions: FSharpDiagnosticOptions, diagnosticsLogger: DiagnosticsLogger) =
23112305 inherit DiagnosticsLogger( " DiagnosticsLoggerFilteringByScopedPragmas" )
23122306
2307+ let bugFixed = langVersion.SupportsFeature LanguageFeature.CheckFileBugFixed
2308+
23132309 let mutable realErrorPresent = false
23142310
23152311 override _.DiagnosticSink ( diagnostic : PhasedDiagnostic , severity ) =
@@ -2323,12 +2319,10 @@ type DiagnosticsLoggerFilteringByScopedPragmas
23232319 match diagnostic.Range with
23242320 | Some m ->
23252321 scopedPragmas
2326- |> List.exists ( fun pragma ->
2327- let ( ScopedPragma.WarningOff ( pragmaRange , warningNumFromPragma )) = pragma
2328-
2322+ |> List.exists ( fun ( ScopedPragma.WarningOff ( pragmaRange , warningNumFromPragma )) ->
23292323 warningNum = warningNumFromPragma
2330- && ( not checkFile || m.FileIndex = pragmaRange.FileIndex )
2331- && posGeq m.Start pragmaRange.Start)
2324+ && ( not bugFixed
2325+ || m.FileIndex = pragmaRange.FileIndex && posGeq m.Start pragmaRange.Start) )
23322326 |> not
23332327 | None -> true
23342328
@@ -2344,5 +2338,5 @@ type DiagnosticsLoggerFilteringByScopedPragmas
23442338
23452339 override _.CheckForRealErrorsIgnoringWarnings = realErrorPresent
23462340
2347- let GetDiagnosticsLoggerFilteringByScopedPragmas ( checkFile , scopedPragmas , diagnosticOptions , diagnosticsLogger ) =
2348- DiagnosticsLoggerFilteringByScopedPragmas( checkFile , scopedPragmas, diagnosticOptions, diagnosticsLogger) :> DiagnosticsLogger
2341+ let GetDiagnosticsLoggerFilteringByScopedPragmas ( langVersion , scopedPragmas , diagnosticOptions , diagnosticsLogger ) =
2342+ DiagnosticsLoggerFilteringByScopedPragmas( langVersion , scopedPragmas, diagnosticOptions, diagnosticsLogger) :> DiagnosticsLogger
0 commit comments