[pkg/dart2wasm] use package:lints for analysis

Change-Id: I5a17a8e8a5213dc30f4a2dd29fafac0a2030c722
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250780
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
This commit is contained in:
Devon Carew 2022-07-07 00:16:01 +00:00 committed by Commit Bot
parent 08d2a29233
commit ea43dfee36
7 changed files with 23 additions and 8 deletions

View file

@ -0,0 +1 @@
include: package:lints/core.yaml

View file

@ -293,7 +293,9 @@ class ContextCollector extends RecursiveVisitor {
bool outerMost = currentContext == null;
Context? oldContext = currentContext;
Context? parent = currentContext;
while (parent != null && parent.isEmpty) parent = parent.parent;
while (parent != null && parent.isEmpty) {
parent = parent.parent;
}
currentContext = Context(node, parent);
if (closures.isThisCaptured && outerMost) {
currentContext!.containsThis = true;

View file

@ -357,7 +357,7 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
}
void _implicitReturn() {
if (function.type.outputs.length > 0) {
if (function.type.outputs.isNotEmpty) {
w.ValueType returnType = function.type.outputs[0];
if (returnType is w.RefType && returnType.nullable) {
// Dart body may have an implicit return null.
@ -706,7 +706,9 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
}
bool _hasLogicalOperator(Expression condition) {
while (condition is Not) condition = condition.operand;
while (condition is Not) {
condition = condition.operand;
}
return condition is LogicalExpression;
}

View file

@ -282,7 +282,9 @@ class DispatchTable {
selector.offset = offset;
for (int classId in selector.classIds) {
int entry = offset + classId;
while (table.length <= entry) table.add(null);
while (table.length <= entry) {
table.add(null);
}
assert(table[entry] == null);
table[entry] = selector.targets[classId];
}

View file

@ -508,7 +508,7 @@ class Intrinsifier {
code(b);
return outType;
}
} else if (node.arguments.positional.length == 0) {
} else if (node.arguments.positional.isEmpty) {
// Unary operator
Expression operand = node.receiver;
w.ValueType opType = translator.translateType(receiverType);
@ -1010,9 +1010,9 @@ class Intrinsifier {
ClassInfo intInfo = translator.classInfo[translator.boxedIntClass]!;
ClassInfo doubleInfo = translator.classInfo[translator.boxedDoubleClass]!;
w.Local cid = function.addLocal(w.NumType.i32);
w.Label ref_eq = b.block();
w.Label refEq = b.block();
b.local_get(first);
b.br_on_null(ref_eq);
b.br_on_null(refEq);
b.struct_get(translator.topInfo.struct, FieldIndex.classId);
b.local_tee(cid);

View file

@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// ignore_for_file: non_constant_identifier_names
import 'dart:typed_data';
import 'package:dart2wasm/class_info.dart';
@ -540,7 +542,9 @@ class Translator {
}
w.ArrayType arrayTypeForDartType(DartType type) {
while (type is TypeParameterType) type = type.bound;
while (type is TypeParameterType) {
type = type.bound;
}
return wasmArrayType(
translateStorageType(type), type.toText(defaultAstTextStrategy));
}

View file

@ -11,3 +11,7 @@ dependencies:
kernel: any
vm: any
wasm_builder: any
# Use 'any' constraints here; we get our versions from the DEPS file.
dev_dependencies:
lints: any