Files
sdk/pkg/analyzer/lib
Paul Berry aa00d4844e [flow analysis] Remove skipDuplicateCheck hack.
In https://dart-review.googlesource.com/c/sdk/+/278649, I added
assertions to flow analysis to make sure that `FlowAnalysis.declare`
wasn't called more times than necessary. To work around a few instance
in which it _was_ being called more than necessary, I added a
parameter `skipDuplicateCheck` that caused the assertion to be
skipped.

This change fixes the one remaining case in which skipping the check
was necessary, by moving the CFE logic that calls
`FlowAnalysis.declare` for formal parameters. Previously, this logic
was in both `BodyBuilder.finishFunction` and
`BodyBuilder.finishConstructor`, resulting in some duplication because
`BodyBuilder.finishFunction` sometimes calls
`BodyBuilder.finishConstructor`. I've moved the logic into a new
method, `BodyBuilder._declareFormals`, which is called from
`BodyBuilder.finishFunction` and `BodyBuilder.parseInitializers`,
ensuring that the calls to `FlowAnalysis.declare` only occur once.

Fixing this case allows the `skipDuplicateCheck` hack to be removed
entirely.

Note that there was also one place where the analyzer was also using
`skipDuplicateCheck`, but it was doing so unnecessarily.

Change-Id: Ic34d1b7120f05d94c53774d52eb90e4ada67415f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434261
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-06-13 06:35:23 -07:00
..