dotnet/roslyn

IDE0059 generates ambiguity errors for overloads with `out`

オープン

#38,053 opened on 2019/08/16

 (4 件のコメント) (1 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-IDEBugFeature - IDE0059IDE-CodeStylehelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

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)'

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