Given the following snippet:
type Foo() =
static member Test (act : unit -> unit) = act()
static member Test (act : Action) = Foo.Test act.Invoke
I get an error in the last line: a unique overload for the Test method cannot be determined based on type information up to this point in the program. Type annotation may be required.
Unfortunately, a type annotation (act.Invoke : unit -> unit)does not eliminate the ambiguity, and I cannot find an annotation that corrects it. I would like the version to Actionbe a wrapper around the version ->. My specific use case is the definition of a class that will be called from both F # and C #, so I want it to work from both languages.
source
share