Skip to content

No nullability warning for type inference with lambda argument #30480

@cston

Description

@cston

Method type inference should report a warning that nullability could not be inferred:

using System;
using System.Runtime.CompilerServices;
[module: NonNullTypes]
interface I<T> { }
class C
{
    static void F<T>(Func<bool, T> f)
    {
    }
    static void G(I<object> x, I<object?> y)
    {
        F(b => { if (b) return x; else return y; }); // warning: cannot infer nullability
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions