Skip to content

Incorrect nullability from method type inference #27961

@cston

Description

@cston

The compiler reports a warning for F(x, y).ToString() but not for F(y, x).ToString().

// csc.exe /langversion:7 /t:library a.cs
public class A { }
public class B { public A F; }
// csc.exe /r:a.dll /t:library b.cs
class C
{
    static T F<T>(T x, T y) => x;
    static void G(A? x, B b)
    {
        var y = b.F;
        F(x, y).ToString();
        F(y, x).ToString();
    }
}

(jcouv update:)
Note that I referenced this issue to replace some PROTOTYPE markers. See details below.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions