[dart2js] Use null-aware elements

Change-Id: I2dc74c57efd355ab4871eb2ad48a97fc817a2940
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433300
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams
2025-06-06 12:45:17 -07:00
committed by Commit Queue
parent 5ccfa844da
commit 23ba783c4c
6 changed files with 7 additions and 14 deletions
+1
View File
@@ -21,3 +21,4 @@ linter:
- no_default_cases
- unnecessary_ignore
- unnecessary_statements
- use_null_aware_elements
+1 -2
View File
@@ -1532,8 +1532,7 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
// Assign names to _DeferredNames that were not assigned while visiting a
// generic function type.
Set<String> usedNames = {
for (final deferred in variableToName.values)
if (deferred.name != null) deferred.name!,
for (final deferred in variableToName.values) ?deferred.name,
};
int startGroup = (_genericFunctions?.length ?? 0) + 1;
for (var entry in variableToName.entries) {
+1 -2
View File
@@ -2558,8 +2558,7 @@ class AsyncStarRewriter extends AsyncRewriterBase {
List<int> enclosingFinallyLabels = [
// At the bottom of the stack is the return label.
exitLabel!,
for (final node in jumpTargets)
if (finallyLabels[node] != null) finallyLabels[node]!,
for (final node in jumpTargets) ?finallyLabels[node],
];
addStatement(
@@ -101,7 +101,7 @@ class JsToFrontendMap {
return {
for (final member in set.map(toBackendMember))
// Members that are not live don't have a corresponding backend member.
if (member != null) member,
?member,
};
}
@@ -170,7 +170,7 @@ class ListFactorySpecializer extends BaseSpecializer {
)..fileOffset = node.fileOffset;
return BlockExpression(
Block([if (lengthVariable != null) lengthVariable!, listVariable, loop]),
Block([?lengthVariable, listVariable, loop]),
VariableGet(listVariable)..fileOffset = node.fileOffset,
);
}
+2 -8
View File
@@ -3978,7 +3978,7 @@ abstract class HLateCheck extends HCheck {
HInstruction? name,
this.isTrusted,
AbstractValue type,
) : super([input, if (name != null) name], type);
) : super([input, ?name], type);
bool get hasName => inputs.length > 1;
@@ -4989,13 +4989,7 @@ class HArrayFlagsCheck extends HCheck {
HInstruction? operation,
HInstruction? verb,
AbstractValue type,
) : super([
array,
arrayFlags,
checkFlags,
if (operation != null) operation,
if (verb != null) verb,
], type);
) : super([array, arrayFlags, checkFlags, ?operation, ?verb], type);
HInstruction get array => inputs[0];
HInstruction get arrayFlags => inputs[1];