dotnet/roslyn

IDE0059 generates ambiguity errors for overloads with `out`

Open

#38,053 opened on 2019年8月16日

GitHub で見る
 (4 comments) (1 reaction) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-IDEBugFeature - IDE0059IDE-CodeStylehelp wanted

説明

Version Used: 3.3.0-beta3-19413-06+ac06df1bffb7b7fd0e5bf63cc91921af76b21e03

Steps to Reproduce:

class Program
{
    static void Main()
    {
        string s;
        Foo(out s);

        int i;
        Foo(out i);
    }

    static void Foo(out int blah) => blah = 0;
    static void Foo(out string blah) => blah = "";
}

Fix All for IDE0059.

Expected Behavior: IDE0059 shouldn't be offered, or if it is, the generated code should employ some disambiguation mechanism.

Actual Behavior:

class Program
{
    static void Main()
    {
        Foo(out _);
        Foo(out _);
    }

    static void Foo(out int blah) => blah = 0;
    static void Foo(out string blah) => blah = "";
}

which fails to compile:

1>Program.cs(5,9,5,12): error CS0121: The call is ambiguous between the following methods or properties: 'Program.Foo(out int)' and 'Program.Foo(out string)'
1>Program.cs(6,9,6,12): error CS0121: The call is ambiguous between the following methods or properties: 'Program.Foo(out int)' and 'Program.Foo(out string)'

コントリビューターガイド