Skip to content

Signature generation roundtrip issue: SRTP multi-witness constraint on type member #19594

Description

@T-Gro

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions