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

Code before:
                    {
                        if (s == null)
                        {
                        }
                    }
                }

                readonly struct S
                {
                    public static implicit operator S(bool? x) => default;
                    public static bool operator ==(S left, S right) => false;
                    public static bool operator !=(S left, S right) => true;
                    public override bool Equals(object obj) => false;
                    public override int GetHashCode() => 0;
                }
                """;
            CreateCompilation(source).VerifyDiagnostics();
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/8925")]
        public void ParamsErrorSuppression_StringConvertibleToObject()
        {
            // When a method has a params parameter and an argument would be convertible 
            // to the element type when the params is expanded, we should not report an error
            // for that argument. The real error is with another argument that prevents 
            // the method from being applicable.
            var source = """
                class Program
                {
                    static void M(char c, params object[] args) { }
                    
                    static void Test(string[] arr)
                    {
                        // M has: M(char c, params object[] args)
                        // When called with (string[], string), we get:
                        // - First argument fails: string[] -> char
                        // - Second argument would succeed if expanded: string -> object
                        // We should only report the first error, not the second.
                        M(arr, "test");
                    }
                }
                """;
            CreateCompilation(source).VerifyDiagnostics(
                // (12,11): error CS1503: Argument 1: cannot convert from 'string[]' to 'char'
                Diagnostic(ErrorCode.ERR_BadArgType, "arr").WithArguments("1", "string[]", "char").WithLocation(12, 11));
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/8925")]
        public void ParamsErrorSuppression_IntNotConvertibleToString()
        {
            // When a method has a params parameter and an argument would NOT be convertible 

Review comment (suggestion):
@copilot  remove these actual source code comments.  you can keep the comments in the string literal. #Closed

Code after:
                    {
                        if (s == null)
                        {
                        }
                    }
                }

                readonly struct S
                {
                    public static implicit operator S(bool? x) => default;
                    public static bool operator ==(S left, S right) => false;
                    public static bool operator !=(S left, S right) => true;
                    public override bool Equals(object obj) => false;
                    public override int GetHashCode() => 0;
                }
                """;
            CreateCompilation(source).VerifyDiagnostics();
        }

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

        [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()
                    {
                        M(1, 2);
                    }