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

Follow up on comments in ImplicitConversions_07 unit-test #29898

Closed
AlekseyTs opened this issue Sep 14, 2018 · 2 comments · Fixed by #49279
Closed

Follow up on comments in ImplicitConversions_07 unit-test #29898

AlekseyTs opened this issue Sep 14, 2018 · 2 comments · Fixed by #49279

Comments

@AlekseyTs
Copy link
Contributor

        [Fact]
        public void ImplicitConversions_07()
        {
            var source =
@"class A<T>
{
}
class B<T>
{
    public static implicit operator A<T>(B<T> b) => throw null;
}
class C
{
    static B<T> F<T>(T t) => throw null;
    static void G(A<object?> a) => throw null;
    static void Main(object? x)
    {
        var y = F(x);
        G(y); // warning
        if (x == null) return;
        var z =  F(x);
        G(z); // ok
    }
}";
            var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
            // PROTOTYPE(NullableReferenceTypes): Several issues with implicit user-defined conversions and
            // nested nullability: should report `'A<object?>' doesn't match ... 'A<object>'` rather than
            // `'A<object>' doesn't match ... 'A<object?>'`; should report warning for `G(y)` only, not `G(z)`
            // (see NullabilityWalker.ApplyConversion).
            comp.VerifyDiagnostics(
                // (15,11): warning CS8620: Nullability of reference types in argument of type 'A<object>' doesn't match target type 'A<object?>' for parameter 'a' in 'void C.G(A<object?> a)'.
                //         G(y); // warning
                Diagnostic(ErrorCode.WRN_NullabilityMismatchInArgument, "y").WithArguments("A<object>", "A<object?>", "a", "void C.G(A<object?> a)").WithLocation(15, 11),
                // (18,11): warning CS8620: Nullability of reference types in argument of type 'A<object>' doesn't match target type 'A<object?>' for parameter 'a' in 'void C.G(A<object?> a)'.
                //         G(z); // ok
                Diagnostic(ErrorCode.WRN_NullabilityMismatchInArgument, "z").WithArguments("A<object>", "A<object?>", "a", "void C.G(A<object?> a)").WithLocation(18, 11));
        }
@AlekseyTs
Copy link
Contributor Author

I am not sure if the expectations stated in the comment are correct. It feels like the warning reported for G(z) is correct and there should be no warning for G(y).

@jaredpar jaredpar added the Bug label Sep 17, 2018
@jaredpar jaredpar added this to the 16.0 milestone Sep 17, 2018
@gafter gafter modified the milestones: 16.0, 16.1 Feb 26, 2019
@jaredpar
Copy link
Member

jaredpar commented Apr 9, 2019

Looks like this is being tracked by #29605. The code in NullableWalker uses that issue when referring to this test case.

jaredpar added a commit to jaredpar/roslyn that referenced this issue Apr 12, 2019
This dupes dotnet#29898 to dotnet#29605 and cleans up the related comment

closes dotnet#29898
@jcouv jcouv modified the milestones: 16.1, 16.2 Apr 23, 2019
@jcouv jcouv modified the milestones: 16.2, 16.3 Jun 25, 2019
@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants