Files
sdk/tests/language/nnbd
Paul Berry 922f212340 [analyzer] Fix null shorting extent in cascade sections.
When a cascade section contains a null-aware expression, the null
shorting should be terminated at the end of the cascade section. For
example, in the statement:

    e..x?.f()..g();

if `e.x` evaluates to `null`, the call to `f()` should be skipped, but
not the call to `g()`.

Prior to this fix, the analyzer erroneously considered the null
shorting to be terminated at the end of the entire cascade. The
mistake wasn't easily observed, since the analyzer doesn't have
back-end semantics. But it was still observable in some rare cases
involving type promotion. For example, in the statement:

    e..x?.f(i!)..g(i!);

the analyzer would consider the second `!` to be unnecessary, because
in its model of flow control, `g(i!)` would only ever execute after
`f(i!)`.

Fixes https://github.com/dart-lang/sdk/issues/59658.

Bug: https://github.com/dart-lang/sdk/issues/59658
Change-Id: I8540daca121dac6960f8d6a2a3ffa3e38a0bf921
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398926
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-12-06 17:54:50 +00:00
..