Open
Description
Description
It seems that when a member is shadowing an inherited member with a different return type, the return type is not considered to avoid any ambiguity when the compiler is attempting to resolve the member.
Repro steps
Self-explanatory example:
type Mother() =
member this.Hello() =
Unchecked.defaultof<int32>
type Daughter() =
inherit Mother()
member this.Hello() =
Unchecked.defaultof<string>
type SomeoneHolder<'Someone when 'Someone: (member Hello : unit -> string)> =
{ Someone: 'Someone }
let someoneHolder =
{ Someone = Daughter() }
Expected behavior
It should compile.
Actual behavior
It does not, with the error below:
[FS0001] A unique overload for method 'Hello' could not be determined based on type information prior to this program point.
A type annotation may be needed. Candidates:member Daughter.Hello : unit -> string
,member Mother.Hello : unit -> int32
Known workarounds
None.
Related information
Provide any related information (optional):
The return type
- Operating system: Windows 10 Enterprise
- .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET Core 3.1
- Editing Tools (e.g. Visual Studio Version, Visual Studio): Rider
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
New