Skip to content

Overload resolution does not eliminate incompatible Nullable candidates #13731

@NinoFloris

Description

@NinoFloris

Found in #13673

type M() =
    static member A(n: System.Nullable<char>) = printfn "1"
    static member A(n: int) = printfn "4"
let test(x: 'T) =
    M.A(x)

If we know nothing we should prefer int, 'T should always be better than Nullable<'T>. Today we produce an ambiguity error.

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AbEAzAzmgFxAEsMAfAgTwAcYACAWQAoBKOgXgFgAoOvu3AQCGBYmDoBbGBOAwodAIJMAdiDoBlSoOkA6AHIBXDBiHAMMADxgAFkKgA+NuzrUoxZQWzK6AIgCMPjz8AsKi4lIycooqau4ETi5uHl6+KIHc5gR0BDCCTAhqAOQAKk5B/Aw6SggsQA===

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions