Repository: dotnet/roslyn
File: src/Compilers/CSharp/Test/Semantic/Semantics/OverloadResolutionTests.cs (C#)

Code before:
        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/12933")]
        public void ParamsErrorSuppression_IntNotConvertibleToString()
        {
            var source = """
                class C
                {
                    static void M(char c, params string[] args) { }
                    
                    static void Test()
                    {
                        // First argument fails: int -> char
                        // Second argument also fails even if expanded: int -> string
                        // We should report both errors.
                        M(1, 2);
                    }
                }
                """;
            CreateCompilation(source).VerifyDiagnostics(
                // (10,11): error CS1503: Argument 1: cannot convert from 'int' to 'char'
                Diagnostic(ErrorCode.ERR_BadArgType, "1").WithArguments("1", "int", "char").WithLocation(10, 11),
                // (10,14): error CS1503: Argument 2: cannot convert from 'int' to 'string'
                Diagnostic(ErrorCode.ERR_BadArgType, "2").WithArguments("2", "int", "string").WithLocation(10, 14));
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/43920")]
        public void ParamsErrorSuppression_Issue43920()
        {
            var source = """
                class Program
                {
                    static void M(int x, params object[] args) { }
                    
                    static void Test()
                    {
                        // First argument fails: string -> int
                        // Second argument would succeed if expanded: string -> object
                        // We should only report the first error.
                        M("wrong", "test");
                    }
                }
                """;
            CreateCompilation(source).VerifyDiagnostics(
                // (10,11): error CS1503: Argument 1: cannot convert from 'string' to 'int'
                Diagnostic(ErrorCode.ERR_BadArgType, "\"wrong\"").WithArguments("1", "string", "int").WithLocation(10, 11));
        }
    }
}


Review comment (suggestion):
@copilot https://github.com/dotnet/roslyn/issues/43920 uses this signature: `static void A(string a, params string[] b) { }`  add a test case for this as well. #Closed

Code after:
                class C
                {
                    static void M(char c, params string[] args) { }
                    
                    static void Test()
                    {
                        M(1, 2);
                    }
                }
                """;
            CreateCompilation(source).VerifyDiagnostics(
                // (7,11): error CS1503: Argument 1: cannot convert from 'int' to 'char'
                //         M(1, 2);
                Diagnostic(ErrorCode.ERR_BadArgType, "1").WithArguments("1", "int", "char").WithLocation(7, 11),
                // (7,14): error CS1503: Argument 2: cannot convert from 'int' to 'string'
                //         M(1, 2);
                Diagnostic(ErrorCode.ERR_BadArgType, "2").WithArguments("2", "int", "string").WithLocation(7, 14));
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/43920")]
        public void ParamsErrorSuppression_Issue43920()
        {
            var source = """
                class Program
                {
                    static void M(int x, params object[] args) { }
                    
                    static void Test()
                    {
                        M("wrong", "test");
                    }
                }
                """;
            CreateCompilation(source).VerifyDiagnostics(
                // (7,11): error CS1503: Argument 1: cannot convert from 'string' to 'int'
                //         M("wrong", "test");
                Diagnostic(ErrorCode.ERR_BadArgType, @"""wrong""").WithArguments("1", "string", "int").WithLocation(7, 11));
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/43920")]
        public void ParamsErrorSuppression_Issue43920_StringParams()
        {
            var source = """
                class Program
                {
                    static void A(string a, params string[] b) { }
                    
                    static void Test()
                    {
                        A(1, "test");
                    }