Overload resolution does not eliminate incompatible Nullable candidates
Open
Area-Compiler-Checking
Area-Compiler-Checking-Overloads
Feature Request
Needs-RFC
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Found in https://github.com/dotnet/fsharp/pull/13673
```fs
type M() =
static member A(n: System.Nullable) = 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===
Contributor guide
Assessment
This issue has not been assessed yet.