dotnet/roslyn

Nullability no longer honors null check when it is also an assignment

オープン

#44,461 opened on 2020/05/21

 (1 件のコメント) (2 件のリアクション) (1 人の担当者)C# (4,257 件のフォーク)batch import
Area-CompilersBugFeature - Nullable Reference Typeshelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used: master (19 May 2020)

Steps to Reproduce:

  1. Do assignment of the null check expression inside an if statement.

Repro code: https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQBMQGoA+BiAdgVwBtCJhC4ACOXU8gWACgABAJgEZGmBmC1igYQoBvRhTG8eTACwUAsgAoAlMNHi1qtWIBiAex0UAZhQC8FXHADuFXTqUBuDZsdrgewhQCWUAHJFCDhk1xDyN5L19iE0MAOgAFBB0AB0QYAE8KAEJTAmJFZ3ERQKDNJjYATnkDOITkhDTogBUdABkdC0QlRQDiigBfR36GQc5JFms9RkK1bl42AAYAfgp4pJT0oQoAczgYOwooHb3B3qA===

Expected Behavior: Object was already checked for null, nullability should no longer warn "Possible null reference".

Actual Behavior: Nullability still warn "Possible null reference" regardless of the previous null check.

cc @jaredpar @cston @jcouv

コントリビューターガイド