Implementation:
module Lib
let inline RequireM< ^Witnesses, ^T
when (^Witnesses or ^T): (static member M : ^T -> string)> (x: ^T) : string =
((^Witnesses or ^T): (static member M : ^T -> string) x)
type C(p:int) =
member x.P = p
type Witnesses() =
static member M (x: C) : string = sprintf "M(C), x = %d" x.P
static member M (x: int64) : string = sprintf "M(int64), x = %d" x
type StaticMethods =
static member inline M< ^T when (Witnesses or ^T): (static member M: ^T -> string)> (x: ^T) : string =
RequireM< Witnesses, ^T> (x)
Actual generated signature (partial):
val inline RequireM:
x: ^T -> string when (^Witnesses or ^T) : (static member M: ^T -> string)
...
type StaticMethods =
static member
inline M: x: ^T -> string
when (Witnesses or ^T) : (static member M: ^T -> string)
Note: RequireM uses ^Witnesses (hat). StaticMethods.M uses Witnesses (no hat). Should be ^Witnesses.
Error on roundtrip compile:
error FS0340: The signature and implementation are not compatible because the declaration of the type parameter requires a constraint of the form (^Witnesses or ^T) : (static member M: ^T -> string)
Expected signature:
[<Class>]
type StaticMethods =
static member inline M< ^T when (Witnesses or ^T) : (static member M: ^T -> string)> : x: ^T -> string
Verified: roundtrips successfully with explicit type param syntax.
Implementation:
Actual generated signature (partial):
Note:
RequireMuses^Witnesses(hat).StaticMethods.MusesWitnesses(no hat). Should be^Witnesses.Error on roundtrip compile:
Expected signature:
Verified: roundtrips successfully with explicit type param syntax.