> type XList<'T> (_collection : seq<'T>) =
inherit List<'T> (_collection)
member this.Add _item = if not <| this.Contains _item then base.Add _item
new () = XList<'T> (Seq.empty<'T>);;
inherit List<'T> (_collection)
--------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
stdin(47,9): error FS0945: Cannot inherit a sealed type
My understanding is that List<'T> is actually not sealed. No?
Also, this seems to work just fine outside F# interactive. That exact code is in my F# project, and the compiler processes it without complaining. I've got the same thing going on in a couple of C# projects. The code works as expected in every case.
Normally, I'd just extend List<'T> with a static method (doing it the "F# way"), but hiding List.Add should work fine, too.