Skip to content

Update methods from initial binding based on inferred nullability #29605

@cston

Description

@cston

There are a number of cases in NullableWalker where methods from initial binding should be updated based on the inferred nullability.

For instance, both calls to .ToString() below should report warnings but no warning is reported for the second case currently.

#nullable enable
class C<T>
{
    internal T F() => throw null;
}
class Program
{
    static C<T> Create<T>(T t)
    {
        return new C<T>();
    }
    static void F(string? s)
    {
        new C<string?>().F().ToString(); // warning: maybe null
        Create(s).F().ToString();        // no warning
    }
}

Test cases affected: NullableReferenceTypesTests.ImplicitConversions_07

[jcouv update:] both calls to .ToString() now report warnings (sharplab) but more references to this issue remain in the source.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions