Skip to content

Null check with 'as' does not update nullable state #38522

@sharwell

Description

@sharwell

Version Used: 16.3 Preview 2

Steps to Reproduce:

SomeType? value = null;
if (value?.Property as AnotherType != null)
{
  _ = value.Property;
}

SomeType? value2 = null;
if (value2?.Property is AnotherType)
{
  _ = value2.Property;
}

Expected Behavior:

No warning is reported on the access of value.Property or value2.Property.

Actual Behavior:

A warning is reported on the access of value.Property, but no warning is reported on the access of value2.Property.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions