Skip to content

Unable to override overloaded mixed (non)virtual methods #14613

@kerams

Description

@kerams

Repro steps

type Strrr () =
    inherit System.IO.Stream ()

    override _.FlushAsync ct = null

Set <LangVersion>preview</LangVersion>.

Expected behavior

FlushAsync is overridden, no errors reported.

Actual behavior

Intellisense in VS reports No abstract or interface member was found that corresponds to this override, because the entire method signature is not taken into account - the base method with matching signature is virtual.

The code still compiles since the regression was introduced in #14263, which did not make it to .NET 7.

Known workarounds

Use lang version 7.0.

Related information

  • VS 17.5.0 Preview 2.0

This test needs to pass:

    [<Fact>]
    let ``Virtual member was found among virtual and non-virtual overloads with lang preview`` () =
        let CSLib =
            CSharp """
public class A
{
    public void M1(int i) { }
    public virtual void M1(string s) { }
}
        """ |> withName "CSLib"

        let app =
            FSharp """
module ClassTests

type Over () =
    inherit A ()

    override _.M1 (s: string) = ()
        """
        
        app
        |> withReferences [CSLib]
        |> withLangVersionPreview
        |> compile
        |> shouldSucceed

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions