-
Notifications
You must be signed in to change notification settings - Fork 847
Description
Thanks to @TIHan for bringing this up. Consider the following example:
[<AbstractClass; Sealed>]
type One =
static member M(x: int) = 1
[<AbstractClass; Sealed>]
type Two =
static member M(x: float) = 1
open One
open Two
let x = M(1.0)
let y = M(1) // Compile error!The M that takes an int is shadowed, as if these were functions.
However, this feels quite unexpected since these are methods, and methods can be overloaded. And as you'd expect, if both M methods were defined in the same static class, you could write code that used both overloads. And since they have unique signatures, it's expected that you could call either.
Hence, I consider this behavior to be unexpected and/or a bug and not an explicit design decision.
However, fixing it is not so simple. Because it is possible to write F# code that calls overloaded methods but uses type inference, allowing the compiler to "see" additional overloads is a breaking change. A key distinction here is that, unlike a library or CoreFX adding an overload that causes this if people upgrade, this would be the F# compiler potentially introducing a breaking change into user code.
Hence, it is a breaking change to fix this if the feature is fully released. We have two options:
- Try to get in a fix ASAP
- Put the feature behind the
previewlanguage version and fix the bug that way