@@ -10,12 +10,13 @@ open System.Threading
1010open Internal.Utilities .Collections
1111open Internal.Utilities .Library
1212open Internal.Utilities .Library .Extras
13+
1314open FSharp.Compiler
1415open FSharp.Compiler .AbstractIL
1516open FSharp.Compiler .AbstractIL .IL
1617open FSharp.Compiler .AbstractIL .ILBinaryReader
1718open FSharp.Compiler .CodeAnalysis
18- open FSharp.Compiler .CheckExpressions
19+ open FSharp.Compiler .CheckBasics
1920open FSharp.Compiler .CheckDeclarations
2021open FSharp.Compiler .CompilerConfig
2122open FSharp.Compiler .CompilerDiagnostics
@@ -24,8 +25,8 @@ open FSharp.Compiler.CompilerImports
2425open FSharp.Compiler .CompilerOptions
2526open FSharp.Compiler .DependencyManager
2627open FSharp.Compiler .Diagnostics
28+ open FSharp.Compiler .DiagnosticsLogger
2729open FSharp.Compiler .Driver
28- open FSharp.Compiler .ErrorLogger
2930open FSharp.Compiler .NameResolution
3031open FSharp.Compiler .ParseAndCheckInputs
3132open FSharp.Compiler .ScriptClosure
@@ -44,7 +45,7 @@ open FSharp.Compiler.BuildGraph
4445// InteractiveChecker
4546//-------------------------------------------------------------------------
4647
47- type internal TcResult = TcEnv * TopAttribs * TypedImplFile option * ModuleOrNamespaceType
48+ type internal TcResult = TcEnv * TopAttribs * CheckedImplFile option * ModuleOrNamespaceType
4849type internal TcErrors = FSharpDiagnostic[]
4950
5051type internal CompilerState = {
@@ -109,19 +110,18 @@ module internal ParseAndCheck =
109110 let initializeCompilerState projectOptions reset = async {
110111 let tcConfig =
111112 let tcConfigB =
112- TcConfigBuilder.CreateNew( SimulatedMSBuildReferenceResolver.getResolver(),
113- includewin32manifest= false ,
114- framework= false ,
115- portablePDB= false ,
116- defaultFSharpBinariesDir= FSharpCheckerResultsSettings.defaultFSharpBinariesDir,
117- reduceMemoryUsage= ReduceMemoryFlag.Yes,
118- implicitIncludeDir= Path.GetDirectoryName( projectOptions.ProjectFileName),
119- isInteractive= false ,
120- isInvalidationSupported= true ,
121- defaultCopyFSharpCore= CopyFSharpCoreFlag.No,
122- tryGetMetadataSnapshot=( fun _ -> None),
123- sdkDirOverride= None,
124- rangeForErrors= range0)
113+ TcConfigBuilder.CreateNew(
114+ SimulatedMSBuildReferenceResolver.getResolver(),
115+ defaultFSharpBinariesDir = FSharpCheckerResultsSettings.defaultFSharpBinariesDir,
116+ reduceMemoryUsage = ReduceMemoryFlag.Yes,
117+ implicitIncludeDir = Path.GetDirectoryName( projectOptions.ProjectFileName),
118+ isInteractive = false ,
119+ isInvalidationSupported = true ,
120+ defaultCopyFSharpCore = CopyFSharpCoreFlag.No,
121+ tryGetMetadataSnapshot = ( fun _ -> None),
122+ sdkDirOverride = None,
123+ rangeForErrors = range0
124+ )
125125 let sourceFiles = projectOptions.SourceFiles |> Array.toList
126126 let argv = projectOptions.OtherOptions |> Array.toList
127127 let _sourceFiles = ApplyCommandLineArgs( tcConfigB, sourceFiles, argv)
@@ -140,10 +140,9 @@ module internal ParseAndCheck =
140140 ccu.Deref.InvalidateEvent.Add( fun _ -> reset())
141141 )
142142
143- let niceNameGen = NiceNameGenerator()
144143 let assemblyName = projectOptions.ProjectFileName |> Path.GetFileNameWithoutExtension
145144 let tcInitial , openDecls0 = GetInitialTcEnv ( assemblyName, rangeStartup, tcConfig, tcImports, tcGlobals)
146- let tcInitialState = GetInitialTcState ( rangeStartup, assemblyName, tcConfig, tcGlobals, tcImports, niceNameGen , tcInitial, openDecls0)
145+ let tcInitialState = GetInitialTcState ( rangeStartup, assemblyName, tcConfig, tcGlobals, tcImports, tcInitial, openDecls0)
147146
148147 // parse cache, keyed on file name and source hash
149148 let parseCache = ConcurrentDictionary< string * int, FSharpParseFileResults>( HashIdentity.Structural)
@@ -162,14 +161,14 @@ module internal ParseAndCheck =
162161 }
163162
164163 let MakeProjectResults ( projectFileName : string , parseResults : FSharpParseFileResults [], tcState : TcState , errors : FSharpDiagnostic [],
165- topAttrsOpt : TopAttribs option , tcImplFilesOpt : TypedImplFile list option ,
166- compilerState ) =
164+ topAttrsOpt : TopAttribs option , tcImplFilesOpt : CheckedImplFile list option , compilerState ) =
167165 let assemblyRef = mkSimpleAssemblyRef " stdin"
168166 let access = tcState.TcEnvFromImpls.AccessRights
169167 let symbolUses = Choice2Of2 TcSymbolUses.Empty
170168 let dependencyFiles = parseResults |> Seq.map ( fun x -> x.DependencyFiles) |> Array.concat
169+ let getAssemblyData () = None
171170 let details = ( compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu, tcState.CcuSig, symbolUses, topAttrsOpt,
172- assemblyRef, access, tcImplFilesOpt, dependencyFiles, compilerState.projectOptions)
171+ getAssemblyData , assemblyRef, access, tcImplFilesOpt, dependencyFiles, compilerState.projectOptions)
173172 let keepAssemblyContents = true
174173 FSharpCheckProjectResults ( projectFileName, Some compilerState.tcConfig, keepAssemblyContents, errors, Some details)
175174
@@ -199,20 +198,21 @@ module internal ParseAndCheck =
199198
200199 let TypeCheckOneInputEntry ( parseResults : FSharpParseFileResults , tcSink : TcResultsSink , tcState : TcState , moduleNamesDict : ModuleNamesDict , compilerState ) =
201200 let input = parseResults.ParseTree
202- let capturingErrorLogger = CompilationErrorLogger( " TypeCheckFile" , compilerState.tcConfig.errorSeverityOptions)
203- let errorLogger = GetErrorLoggerFilteringByScopedPragmas( false , GetScopedPragmasForInput( input), capturingErrorLogger)
204- use _errorScope = new CompilationGlobalsScope ( errorLogger, BuildPhase.TypeCheck)
201+ let diagnosticsOptions = compilerState.tcConfig.diagnosticsOptions
202+ let capturingLogger = CompilationDiagnosticLogger( " TypeCheckFile" , diagnosticsOptions)
203+ let diagnosticsLogger = GetDiagnosticsLoggerFilteringByScopedPragmas( false , input.ScopedPragmas, diagnosticsOptions, capturingLogger)
204+ use _scope = new CompilationGlobalsScope ( diagnosticsLogger, BuildPhase.TypeCheck)
205205
206- let checkForErrors () = parseResults.ParseHadErrors || errorLogger .ErrorCount > 0
206+ let checkForErrors () = parseResults.ParseHadErrors || diagnosticsLogger .ErrorCount > 0
207207 let prefixPathOpt = None
208208
209209 let input , moduleNamesDict = input |> DeduplicateParsedInputModuleName moduleNamesDict
210210 let tcResult , tcState =
211- TypeCheckOneInput ( checkForErrors, compilerState.tcConfig, compilerState.tcImports, compilerState.tcGlobals, prefixPathOpt, tcSink, tcState, input, false )
212- |> Cancellable.runWithoutCancellation
211+ CheckOneInput ( checkForErrors, compilerState.tcConfig, compilerState.tcImports, compilerState.tcGlobals, prefixPathOpt, tcSink, tcState, input, false )
212+ |> Cancellable.runWithoutCancellation
213213
214214 let fileName = parseResults.FileName
215- let tcErrors = DiagnosticHelpers.CreateDiagnostics ( compilerState.tcConfig.errorSeverityOptions , false , fileName, ( capturingErrorLogger .GetDiagnostics()), suggestNamesForErrors)
215+ let tcErrors = DiagnosticHelpers.CreateDiagnostics ( diagnosticsOptions , false , fileName, ( capturingLogger .GetDiagnostics()), suggestNamesForErrors)
216216 ( tcResult, tcErrors), ( tcState, moduleNamesDict)
217217
218218 let CheckFile ( projectFileName : string , parseResults : FSharpParseFileResults , tcState : TcState , moduleNamesDict : ModuleNamesDict , compilerState ) =
@@ -239,7 +239,7 @@ module internal ParseAndCheck =
239239 let checkCacheKey = parseRes.FileName
240240
241241 let typeCheckOneInput _fileName =
242- TypeCheckOneInputEntry ( parseRes, TcResultsSink.NoSink, tcState, moduleNamesDict, compilerState)
242+ TypeCheckOneInputEntry ( parseRes, TcResultsSink.NoSink, tcState, moduleNamesDict, compilerState)
243243
244244 let ( result , errors ), ( tcState , moduleNamesDict ) = compilerState.checkCache.GetOrAdd( checkCacheKey, typeCheckOneInput)
245245
@@ -257,9 +257,9 @@ module internal ParseAndCheck =
257257
258258 let tcResults , tcErrors = Array.unzip results
259259 let ( tcEnvAtEndOfLastFile , topAttrs , implFiles , _ccuSigsForFiles ), tcState =
260- TypeCheckMultipleInputsFinish ( tcResults |> Array.toList, tcState)
260+ CheckMultipleInputsFinish ( tcResults |> Array.toList, tcState)
261261
262- let tcState , declaredImpls , ccuContents = TypeCheckClosedInputSetFinish ( implFiles, tcState)
262+ let tcState , declaredImpls , ccuContents = CheckClosedInputSetFinish ( implFiles, tcState)
263263 tcState.Ccu.Deref.Contents <- ccuContents
264264 tcState, topAttrs, declaredImpls, tcEnvAtEndOfLastFile, moduleNamesDict, tcErrors
265265
@@ -304,11 +304,11 @@ type InteractiveChecker internal (compilerStateCache) =
304304 TypeCheckClosedInputSet ( parseResults, compilerState.tcInitialState, compilerState, None)
305305
306306 let ctok = CompilationThreadToken()
307- let errors , errorLogger , _loggerProvider = CompileHelpers.mkCompilationErrorHandlers ()
307+ let errors , diagnosticsLogger , _loggerProvider = CompileHelpers.mkCompilationDiagnosticsHandlers ()
308308 let exitCode =
309- CompileHelpers.tryCompile errorLogger ( fun exiter ->
310- compileOfTypedAst ( ctok, compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu,
311- tcImplFiles, topAttrs, compilerState.tcConfig, outFile, errorLogger , exiter))
309+ CompileHelpers.tryCompile diagnosticsLogger ( fun exiter ->
310+ CompileFromTypedAst ( ctok, compilerState.tcGlobals, compilerState.tcImports, tcState.Ccu,
311+ tcImplFiles, topAttrs, compilerState.tcConfig, outFile, diagnosticsLogger , exiter))
312312
313313 return errors.ToArray(), exitCode
314314 }
@@ -340,7 +340,7 @@ type InteractiveChecker internal (compilerStateCache) =
340340 fileNames |> Array.map parseFile
341341
342342 // type check files
343- let ( tcState , topAttrs , tcImplFiles , _tcEnvAtEnd , _moduleNamesDict , tcErrors ) = // measureTime <| fun _ ->
343+ let ( tcState , topAttrs , tcImplFiles , _tcEnvAtEnd , _moduleNamesDict , tcErrors ) =
344344 TypeCheckClosedInputSet ( parseResults, compilerState.tcInitialState, compilerState, subscriber)
345345
346346 // make project results
0 commit comments