Oddities in statically resolved method constraints and method overloading
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Case 1
```
type Test() =
member __.Equals (_: Test) = true
let inline Equals(a: obj) (b: ^t) =
match a with
| :? ^t as x -> (^t: (member Equals: ^t -> bool) (b, x))
| _-> false
let a: Test = Test()
let b:Test = Test()
//b <- null
printfn "%A" (Equals a b)
```
I expected to call Test.Equals: Test->unit, (Equals a b) return true
but actually it call Object.Equals: obj->unit, return false
Case 2:
```
type X =
static member Method (a: obj) = 1
static member Method (a: int) = 2
static member Method (a: int64) = 3
let inline Test< ^t, ^a when ^t: (static member Method: ^a -> int)> (value: ^a) =
( ^t: (static member Method: ^a -> int)(value))
let inline Test2< ^t> a = Test a
printfn "%d" (Test2 0)
```
I expected return 2, but actually it return 1
Contributor guide
Assessment
This issue has not been assessed yet.