Skip to content

Incorrect overload resolution when using interface #3125

Description

@francotiveron
type IApi<'t> = 
    (*1*)abstract member Then: ('t -> 'msg) * (exn -> 'msg) -> Cmd<'msg>
    (*2*)abstract member Then: ('t -> unit) * (exn -> unit) -> unit

type Api<'t>(operation: unit -> Async<'t>) = 
    (*3*)member __.Then(msgConstructor: 't -> 'msg, errConstructor: exn -> 'msg) = Cmd.OfAsync.either operation () msgConstructor errConstructor
    (*4*)member __.Then(onSuccess: 't -> unit, onError: exn -> unit) = operation() |> Async.StartAsPromise |> Promise.eitherEnd onSuccess onError
    interface IApi<'t> with
        (*5*)member this.Then(msgConstructor: 't -> 'msg, errConstructor: exn -> 'msg) : Cmd<'msg> = this.Then(msgConstructor, errConstructor)
        (*6*)member this.Then(onSuccess: 't -> unit, onError: exn -> unit): unit = this.Then(onSuccess, onError)

type T = ...

type Msg = 
  | Msg1 of T
  | Msg2 of exn

//f of type unit -> Async<T>
let create1() = Api(f)
let create2(): IApi<_> = Api(f)

let api1 = create1()
api1.Then(Msg1, Msg2) //No problem: Ctrl+Click (design time VS Code) jumps to (*3*); at runtime (*3*) is called

let api2 = create2()
api2.Then(Msg1, Msg2) //PROBLEM: Ctrl+Click (design time VS Code) jumps to (*1*) as expected; HOWEVER, at runtime (*6->4*) is called, instead of the expected (*5->3*)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions