-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).type-questionA question about expected behavior or functionalityA question about expected behavior or functionality
Description
Came up in flutter/flutter#133581 (comment), where the getter debugParentDataType is being added to ParentDataElement<ParentData>
There are two casts below that seem like they should not be necessary, but are flagged as necessary by the analyzer for:
- (1) two complaints from the analyzer
- unchecked_use_of_nullable_value (but we already know it is not null)
- undefined_getter (but we already know it is
ParentDataElement<ParentData>notElement)
- (2) one complaint
- undefined_getter (but we already, now definitely, know it is
ParentDataElement<ParentData>notElement)
- undefined_getter (but we already, now definitely, know it is
Element? ancestor = _parent;
while (ancestor != null && ancestor is! RenderObjectElement) {
if (ancestor is ParentDataElement<ParentData>) {
assert(() {
if (!debugAncestorTypes.add(ancestor.runtimeType)) {
debugAncestorCulprits.add(ancestor.runtimeType);
}
// Both of the following casts are required by the analyzer
// (1)
if (!debugParentDataTypes.add((ancestor! as ParentDataElement<ParentData>).debugParentDataType)) {
// (2)
if (!debugParentDataCulprits.contains((ancestor as ParentDataElement<ParentData>).debugParentDataType)) {
// Add the first one we had put in the Set of Types.
debugParentDataCulprits.add(ancestor.debugParentDataType);
}
debugParentDataCulprits.add(ancestor.debugParentDataType);
}
return true;
}());
result.add(ancestor);
}
ancestor = ancestor._parent;
}Metadata
Metadata
Assignees
Labels
area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).Dart language related items (some items might be better tracked at github.com/dart-lang/language).type-questionA question about expected behavior or functionalityA question about expected behavior or functionality