Skip to content

Local of unconstrained type parameter type is reported as NotAnnotated when using var #46236

@cston

Description

@cston

The local returned from SemanticModel.GetDeclaredSymbol() for y1 has Type.NullableAnnotation == NullableAnnotation.NotAnnotated, but should be NullableAnnotation.Annotated instead.

Compare with the GetDeclaredSymbol() result for y2 which has Type.NullableAnnotation == NullableAnnotation.Annotated.

#nullable enable

class Program
{
    static T F1<T>(T x1)
    {
        var y1 = x1;
        y1 = default(T);
        return y1;
    }

    static T F2<T>(T x2) where T : class
    {
        var y2 = x2;
        y2 = default(T);
        return y2;
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions