Migration: remove unnecessary EdgeBuilder._requiredHintedParameters

The only elements that were ever stored in this set were parameter
elements, and the only time this field was used was in the condition
`... && !_requiredHintedParameters.contains(staticElement) &&
!_flowAnalysis.isAssigned(staticElement)`.  However, flow analysis
considers parameter elements to always be assigned.  Therefore, if
`!_flowAnalysis.isAssigned(staticElement)` is satisfied, then
`!_flowAnalysis.isAssigned(staticElement)` must also be true.  So
testing the two of them is redundant.  And therefore we can remove
tracking of EdgeBuilder._requiredHintedParameters entirely without
affecting behavior.

The reason I want to do this is because we had a confusing
inconsistency in how we were populating
EdgeBuilder._requiredHintedParameters: we were only tracking
parameters whose hints took the form `/*required*/`; we were not
tracking parameters whose hints took the form `@required`.  It seems
like since the whole variable has no effect, it's better to just
remove it rather than fix the inconsistency.

Change-Id: I3b36317e60e08b0577c504a773428b85fb9cdce1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203825
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2021-06-17 22:50:21 +00:00 committed by commit-bot@chromium.org
parent c995253bbe
commit 25c09d052e

View file

@ -220,8 +220,6 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
final Set<PromotableElement> _lateHintedLocals = {};
final Set<PromotableElement> _requiredHintedParameters = {};
final Map<Token, HintComment> _nullCheckHints = {};
/// Helper that assists us in transforming Iterable methods to their "OrNull"
@ -808,7 +806,6 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
} else if (_variables.getRequiredHint(source, node) != null) {
// Nothing to do; assume the implicit default value of `null` will never
// be reached.
_requiredHintedParameters.add(node.declaredElement);
} else {
_graph.makeNullable(
getOrComputeElementType(node, node.declaredElement).node,
@ -1647,7 +1644,6 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
if (!node.inDeclarationContext() &&
node.inGetterContext() &&
!_lateHintedLocals.contains(staticElement) &&
!_requiredHintedParameters.contains(staticElement) &&
!_flowAnalysis.isAssigned(staticElement)) {
_graph.makeNullable(type.node, UninitializedReadOrigin(source, node));
}