fsharp
fsharp copied to clipboard
`open type T` treated as unused when unqualified extension member on `T` used
See also #17619, but this issue applies to all types.
Repro steps
type T =
static member A = 99
[<AutoOpen>]
module M =
type T with
static member Lol = 3
// Shows as unused; the unused opens analyzer will suggest removing it…
open type T
// …Even though it's used.
let lol = Lol
Expected behavior
An open type declaration should be considered used if an unqualified use of an extension member on the type depends on it.
Actual behavior
An open type declaration is not considered used even if an unqualified use of an extension member on the type depends on it.
Known workarounds
N/A.
Related information
.NET 8, 9.
I haven't looked into the cause, but this exhibits the same problem:
module M =
type E = A | B
open type M.E // Considered unused, even though it is.
let f x =
match x with
| A -> ()
| B -> ()
So it's possible that it has more to do with module nesting than extension members specifically.