@@ -1432,19 +1432,22 @@ let CheckMultipleInputsSequential (ctok, checkForErrors, tcConfig, tcImports, tc
14321432 ( tcState, inputs)
14331433 ||> List.mapFold ( CheckOneInputEntry args)
14341434
1435+
1436+ type PartialResult = TcEnv * TopAttribs * CheckedImplFile option * ModuleOrNamespaceType
1437+
14351438/// Use parallel checking of implementation files that have signature files
14361439let CheckMultipleInputsInParallel
1437- (
1438- ctok ,
1440+ (( ctok ,
14391441 checkForErrors ,
14401442 tcConfig : TcConfig ,
14411443 tcImports ,
14421444 tcGlobals ,
14431445 prefixPathOpt ,
14441446 tcState ,
14451447 eagerFormat ,
1446- inputs
1447- ) =
1448+ inputs )
1449+ : CompilationThreadToken * ( unit -> bool ) * TcConfig * TcImports * TcGlobals * LongIdent option * TcState * ( PhasedDiagnostic -> PhasedDiagnostic ) * ParsedInput list )
1450+ : PartialResult list * TcState =
14481451
14491452 let diagnosticsLogger = DiagnosticsThreadStatics.DiagnosticsLogger
14501453
@@ -1558,8 +1561,9 @@ let CheckMultipleInputsInParallel2
15581561 tcState ,
15591562 eagerFormat ,
15601563 inputs
1561- ) =
1564+ ) : PartialResult list * TcState =
15621565
1566+ let _ = ctok // TODO Use
15631567 let diagnosticsLogger = DiagnosticsThreadStatics.DiagnosticsLogger
15641568
15651569 // We create one CapturingDiagnosticLogger for each file we are processing and
@@ -1617,7 +1621,7 @@ let CheckMultipleInputsInParallel2
16171621 // This function will type check all the files where it knows all the dependent file have already been seen.
16181622 // The `freeFiles` are a set of file indexes that have been type checked in a previous run.
16191623 // `processedFiles` stores the result of a typed checked file in a mutable fashion.
1620- let rec visit (( currentTcState : TcState , currentPriorErrors : bool ) as state : State ) ( freeFiles : Set < int >) ( processedFiles : Choice < _ , _ > array ) =
1624+ let rec visit (( currentTcState : TcState , currentPriorErrors : bool ) as state : State ) ( freeFiles : Set < int >) ( processedFiles : _ array) =
16211625 // Find files that still needs processing.
16221626 let unprocessedFiles = freeFiles |> Set.difference ( set [| 0 .. lastIndex |])
16231627
@@ -1672,40 +1676,46 @@ let CheckMultipleInputsInParallel2
16721676 )
16731677
16741678 return
1675- ( fun tcState ->
1679+ ( fun ( tcState , _priorErrors : bool ) ->
16761680 let tcState =
16771681 { tcState with
16781682 tcsCreatesGeneratedProvidedTypes =
16791683 tcState.tcsCreatesGeneratedProvidedTypes || createsGeneratedProvidedTypes
16801684 }
16811685
1682- let ccuSigForFile , updateTcState =
1683- AddCheckResultsToTcState
1684- ( tcGlobals,
1685- amap,
1686- false ,
1687- prefixPathOpt,
1688- tcSink,
1689- tcState.tcsTcImplEnv,
1690- input.QualifiedName,
1691- implFile.Signature)
1692- tcState
1693-
1694- fileIndex, Choice1Of2( tcEnvAtEnd, topAttrs, Some implFile, ccuSigForFile), logger, updateTcState)
1686+ let ccuSigForFile , updatedTcState =
1687+ let results =
1688+ tcGlobals,
1689+ amap,
1690+ false ,
1691+ prefixPathOpt,
1692+ tcSink,
1693+ tcState.tcsTcImplEnv,
1694+ input.QualifiedName,
1695+ implFile.Signature
1696+
1697+ AddCheckResultsToTcState results tcState
1698+
1699+ let partialResult = tcEnvAtEnd, topAttrs, Some implFile, ccuSigForFile
1700+ let hasErrors = logger.ErrorCount > 0
1701+ let priorOrCurrentErrors = priorErrors || hasErrors
1702+ let state = updatedTcState, priorOrCurrentErrors
1703+
1704+ fileIndex, partialResult, state
1705+ )
16951706 }
16961707 |> Cancellable.runWithoutCancellation)
16971708 |> fun results ->
16981709 (( currentTcState, currentPriorErrors), results)
1699- ||> Array.fold ( fun ( tcState , priorErrors ) result ->
1710+ ||> Array.fold ( fun state result ->
17001711 // the `result` callback ensure that the TcState is synced correctly after a batch of file has been type checked in parallel.
17011712 // I believe this bit cannot be done in parallel, yet the order in which we fold the state does not matter.
1702- let fileIndex , partialResult , logger , nextTcState = result tcState
1703-
1713+ let fileIndex , partialResult , state = result state
17041714 // Yikes!
1715+ // Nah, it's okay.
17051716 processedFiles.[ fileIndex] <- partialResult
1706-
1707- let priorErrors = priorErrors || ( logger.ErrorCount > 0 )
1708- ( nextTcState, priorErrors))
1717+ state
1718+ )
17091719
17101720 // The next set of free files are the previous ones + the files we just type checked.
17111721 let nextFreeIndexes =
@@ -1720,7 +1730,9 @@ let CheckMultipleInputsInParallel2
17201730
17211731 visit ( tcState, priorErrors) Set.empty ( Array.zeroCreate inputsWithLoggers.Length)
17221732
1723- partialResults, tcState)
1733+ let partialResults = partialResults |> Array.toList
1734+ partialResults, tcState
1735+ )
17241736
17251737let CheckClosedInputSet ( ctok , checkForErrors , tcConfig : TcConfig , tcImports , tcGlobals , prefixPathOpt , tcState , eagerFormat , inputs ) =
17261738 // tcEnvAtEndOfLastFile is the environment required by fsi.exe when incrementally adding definitions
0 commit comments