Skip to content

Commit 1263077

Browse files
Dedupe opens
1 parent 12d8ee7 commit 1263077

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/Compiler/Service/ServiceAnalysis.fs

+6-10
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ module UnusedOpens =
278278

279279
/// Filter out the open statements whose contents are referred to somewhere in the symbol uses.
280280
/// Async to allow cancellation.
281-
let filterOpenStatements (symbolUses1: FSharpSymbolUse[], symbolUses2: FSharpSymbolUse[]) openStatements =
281+
let filterOpenStatements (symbolUses1: FSharpSymbolUse[], symbolUses2: FSharpSymbolUse[]) (openStatements: OpenStatement[]) =
282282
async {
283283
// the key is a namespace or module, the value is a list of FSharpSymbolUse range of symbols defined in the
284284
// namespace or module. So, it's just symbol uses ranges grouped by namespace or module where they are _defined_.
@@ -297,17 +297,13 @@ module UnusedOpens =
297297
| _ -> ()
298298
| _ -> ()
299299

300-
// We want to check them from last to first.
301-
// See https://github.com/dotnet/fsharp/issues/16226
302-
let reversedOpenStatements = openStatements |> List.ofArray |> List.rev
300+
let openStatements =
301+
openStatements
302+
|> List.ofArray
303+
|> List.distinctBy (_.OpenedGroups >> List.map (_.OpenedModules >> Array.map _.Entity))
303304

304305
let! results =
305-
filterOpenStatementsIncremental
306-
symbolUses2
307-
symbolUsesRangesByDeclaringEntity
308-
reversedOpenStatements
309-
(Dictionary(entityHash))
310-
[]
306+
filterOpenStatementsIncremental symbolUses2 symbolUsesRangesByDeclaringEntity openStatements (Dictionary(entityHash)) []
311307

312308
return results |> List.map (fun os -> os.Range)
313309
}

0 commit comments

Comments
 (0)