Skip to content

Commit 23ba783

Browse files
rakudramaCommit Queue
authored andcommitted
[dart2js] Use null-aware elements
Change-Id: I2dc74c57efd355ab4871eb2ad48a97fc817a2940 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433300 Reviewed-by: Mayank Patke <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent 5ccfa84 commit 23ba783

File tree

6 files changed

+7
-14
lines changed

6 files changed

+7
-14
lines changed

pkg/compiler/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ linter:
2121
- no_default_cases
2222
- unnecessary_ignore
2323
- unnecessary_statements
24+
- use_null_aware_elements

pkg/compiler/lib/src/elements/types.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,8 +1532,7 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
15321532
// Assign names to _DeferredNames that were not assigned while visiting a
15331533
// generic function type.
15341534
Set<String> usedNames = {
1535-
for (final deferred in variableToName.values)
1536-
if (deferred.name != null) deferred.name!,
1535+
for (final deferred in variableToName.values) ?deferred.name,
15371536
};
15381537
int startGroup = (_genericFunctions?.length ?? 0) + 1;
15391538
for (var entry in variableToName.entries) {

pkg/compiler/lib/src/js/rewrite_async.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,8 +2558,7 @@ class AsyncStarRewriter extends AsyncRewriterBase {
25582558
List<int> enclosingFinallyLabels = [
25592559
// At the bottom of the stack is the return label.
25602560
exitLabel!,
2561-
for (final node in jumpTargets)
2562-
if (finallyLabels[node] != null) finallyLabels[node]!,
2561+
for (final node in jumpTargets) ?finallyLabels[node],
25632562
];
25642563

25652564
addStatement(

pkg/compiler/lib/src/js_model/js_to_frontend_map.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class JsToFrontendMap {
101101
return {
102102
for (final member in set.map(toBackendMember))
103103
// Members that are not live don't have a corresponding backend member.
104-
if (member != null) member,
104+
?member,
105105
};
106106
}
107107

pkg/compiler/lib/src/kernel/transformations/modular/list_factory_specializer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class ListFactorySpecializer extends BaseSpecializer {
170170
)..fileOffset = node.fileOffset;
171171

172172
return BlockExpression(
173-
Block([if (lengthVariable != null) lengthVariable!, listVariable, loop]),
173+
Block([?lengthVariable, listVariable, loop]),
174174
VariableGet(listVariable)..fileOffset = node.fileOffset,
175175
);
176176
}

pkg/compiler/lib/src/ssa/nodes.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,7 +3978,7 @@ abstract class HLateCheck extends HCheck {
39783978
HInstruction? name,
39793979
this.isTrusted,
39803980
AbstractValue type,
3981-
) : super([input, if (name != null) name], type);
3981+
) : super([input, ?name], type);
39823982

39833983
bool get hasName => inputs.length > 1;
39843984

@@ -4989,13 +4989,7 @@ class HArrayFlagsCheck extends HCheck {
49894989
HInstruction? operation,
49904990
HInstruction? verb,
49914991
AbstractValue type,
4992-
) : super([
4993-
array,
4994-
arrayFlags,
4995-
checkFlags,
4996-
if (operation != null) operation,
4997-
if (verb != null) verb,
4998-
], type);
4992+
) : super([array, arrayFlags, checkFlags, ?operation, ?verb], type);
49994993

50004994
HInstruction get array => inputs[0];
50014995
HInstruction get arrayFlags => inputs[1];

0 commit comments

Comments
 (0)