Raise a warning if an extension method is ignored
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Every [now](https://stackoverflow.com/questions/45363232/overriding-static-properties-in-f-with-extension-methods) and then this pops up again. Since it confuses users massively, even seasoned programmers, I suggest we raise a warning if an extension method is ignored (that is, if it has an intrinsic method on the original type).
Suggested text to be some variant of:
> warning FS0XXX: Extension method X.Y.Z is hidden by a definition of a static method on the type X.Y that has the same signature.
To raise a warning was suggested before by @dsyme at the bottom of [his comment here](https://github.com/Microsoft/visualfsharp/pull/3582#issuecomment-333669528).
### Repro steps
Consider the following snippet:
```f#
type Single with
/// An override to Single.Parse with fixed InvariantCulture
static member Parse value = Single.Parse(value, floatNumberStyles, CultureInfo.InvariantCulture)
```
### Expected behavior
Most users would expect the code above to be called when using `Single.Parse "4.2"`. But that never happens, the original static member on the type will be called instead.
### Actual behavior
The intrinsic member is called instead.
### Known workarounds
Either specify the full namespace to the extension method (assuming it's different) or use a different member name.
### Related information
This applies to all kinds of methods, properties etc. Static or otherwise.
Contributor guide
Assessment
This issue has not been assessed yet.