From b49db71f3e3eba885802f4006282308ba5855b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Slupik?= Date: Thu, 19 Nov 2020 18:36:12 -0500 Subject: [PATCH] Fix unused open type declaration detection --- src/fsharp/service/ServiceAnalysis.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fsharp/service/ServiceAnalysis.fs b/src/fsharp/service/ServiceAnalysis.fs index f549065fc1cc..71dbdce532af 100644 --- a/src/fsharp/service/ServiceAnalysis.fs +++ b/src/fsharp/service/ServiceAnalysis.fs @@ -67,9 +67,9 @@ module UnusedOpens = yield! getModuleAndItsAutoOpens true ent |] { OpenedModules = getModuleAndItsAutoOpens false modul } - /// Represents single open statement. + /// Represents a single open statement type OpenStatement = - { /// All namespaces and modules which this open declaration effectively opens, including the AutoOpen ones + { /// All namespaces, modules and types which this open declaration effectively opens, including the AutoOpen ones OpenedGroups: OpenedModuleGroup list /// The range of open statement itself @@ -90,7 +90,8 @@ module UnusedOpens = if firstId.idText = MangledGlobalName then None else - Some { OpenedGroups = openDecl.Modules |> List.map OpenedModuleGroup.Create + let openedModulesAndTypes = List.concat [openDecl.Modules; openDecl.Types |> List.map(fun ty -> ty.TypeDefinition)] + Some { OpenedGroups = openedModulesAndTypes |> List.map OpenedModuleGroup.Create Range = range AppliedScope = openDecl.AppliedScope } | _ -> None)