Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve nullability mismatch warning for conversion involving user-defined operator #31798

Open
cston opened this issue Dec 14, 2018 · 0 comments
Labels
Area-Compilers Bug Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Language Feature - Nullable Reference Types Nullable Reference Types
Milestone

Comments

@cston
Copy link
Member

cston commented Dec 14, 2018

Consider improving the warning to reference the user-defined operator:

class A<T> { }

class B
{
    public static implicit operator B(A<object> a) => throw null;
}

class Program
{
    static void F(B b) { }

    static void Main()
    {
        var a = new A<object?>();
        F(a); // warning
    }
}
(15,11): warning CS8620: Nullability of reference types in argument of type 'A<object?>'
    doesn't match target type 'A<object>' for parameter 'b' in 'void Program.F(B b)'.

See #31771 (comment).

@jaredpar jaredpar added the Bug label Jan 2, 2019
@jaredpar jaredpar added this to the 16.0 milestone Jan 2, 2019
@jaredpar jaredpar added this to User Defined Operator in Nullable Board Jan 28, 2019
@gafter gafter modified the milestones: 16.0, 16.1 Feb 26, 2019
@jaredpar jaredpar added the Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. label Apr 9, 2019
@jaredpar jaredpar modified the milestones: 16.1, Compiler.Next Apr 9, 2019
@jaredpar jaredpar modified the milestones: Compiler.Next, Backlog Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Language Feature - Nullable Reference Types Nullable Reference Types
Projects
Nullable Board
User Defined Operator
Development

No branches or pull requests

3 participants