Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ba662eb

Browse files
natebiggsCommit Queue
authored andcommitted
[dart2js] Replace dart2js_dynamic_test with lint and appropriate lint ignores.
See patch 2 for failures coming from this new analysis option. Change-Id: I6bb10c2eb12431f6c503cc817a9c9bb45ba597a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269800 Commit-Queue: Nate Biggs <natebiggs@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
1 parent 50e615e commit ba662eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+143
-151
lines changed

pkg/compiler/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ analyzer:
1111
linter:
1212
rules:
1313
- annotate_overrides
14+
- avoid_dynamic_calls
1415
- prefer_final_fields
1516
- prefer_if_null_operators
1617
- prefer_null_aware_operators

pkg/compiler/lib/src/constants/constant_system.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ class BitAndOperation extends BinaryBitOperation {
307307
BigInt foldInts(BigInt left, BigInt right) => left & right;
308308

309309
@override
310+
// ignore: avoid_dynamic_calls
310311
apply(left, right) => left & right;
311312
}
312313

@@ -320,6 +321,7 @@ class BitOrOperation extends BinaryBitOperation {
320321
BigInt foldInts(BigInt left, BigInt right) => left | right;
321322

322323
@override
324+
// ignore: avoid_dynamic_calls
323325
apply(left, right) => left | right;
324326
}
325327

@@ -333,6 +335,7 @@ class BitXorOperation extends BinaryBitOperation {
333335
BigInt foldInts(BigInt left, BigInt right) => left ^ right;
334336

335337
@override
338+
// ignore: avoid_dynamic_calls
336339
apply(left, right) => left ^ right;
337340
}
338341

@@ -351,6 +354,7 @@ class ShiftLeftOperation extends BinaryBitOperation {
351354
}
352355

353356
@override
357+
// ignore: avoid_dynamic_calls
354358
apply(left, right) => left << right;
355359
}
356360

@@ -384,6 +388,7 @@ class ShiftRightOperation extends BinaryBitOperation {
384388
}
385389

386390
@override
391+
// ignore: avoid_dynamic_calls
387392
apply(left, right) => left >> right;
388393
}
389394

@@ -498,6 +503,7 @@ class SubtractOperation extends ArithmeticNumOperation {
498503
num foldNums(num left, num right) => left - right;
499504

500505
@override
506+
// ignore: avoid_dynamic_calls
501507
apply(left, right) => left - right;
502508
}
503509

@@ -514,6 +520,7 @@ class MultiplyOperation extends ArithmeticNumOperation {
514520
num foldNums(num left, num right) => left * right;
515521

516522
@override
523+
// ignore: avoid_dynamic_calls
517524
apply(left, right) => left * right;
518525
}
519526

@@ -533,6 +540,7 @@ class ModuloOperation extends ArithmeticNumOperation {
533540
num foldNums(num left, num right) => left % right;
534541

535542
@override
543+
// ignore: avoid_dynamic_calls
536544
apply(left, right) => left % right;
537545
}
538546

@@ -552,6 +560,7 @@ class RemainderOperation extends ArithmeticNumOperation {
552560
num foldNums(num left, num right) => left.remainder(right);
553561

554562
@override
563+
// ignore: avoid_dynamic_calls
555564
apply(left, right) => left.remainder(right);
556565
}
557566

@@ -575,6 +584,7 @@ class TruncatingDivideOperation extends ArithmeticNumOperation {
575584
}
576585

577586
@override
587+
// ignore: avoid_dynamic_calls
578588
apply(left, right) => left ~/ right;
579589

580590
@override
@@ -597,6 +607,7 @@ class DivideOperation extends ArithmeticNumOperation {
597607
bool isDivide() => true;
598608

599609
@override
610+
// ignore: avoid_dynamic_calls
600611
apply(left, right) => left / right;
601612
}
602613

@@ -631,6 +642,7 @@ class AddOperation implements BinaryOperation {
631642
}
632643

633644
@override
645+
// ignore: avoid_dynamic_calls
634646
apply(left, right) => left + right;
635647
}
636648

@@ -669,6 +681,7 @@ class LessOperation extends RelationalNumOperation {
669681
bool foldNums(num left, num right) => left < right;
670682

671683
@override
684+
// ignore: avoid_dynamic_calls
672685
apply(left, right) => left < right;
673686
}
674687

@@ -685,6 +698,7 @@ class LessEqualOperation extends RelationalNumOperation {
685698
bool foldNums(num left, num right) => left <= right;
686699

687700
@override
701+
// ignore: avoid_dynamic_calls
688702
apply(left, right) => left <= right;
689703
}
690704

@@ -701,6 +715,7 @@ class GreaterOperation extends RelationalNumOperation {
701715
bool foldNums(num left, num right) => left > right;
702716

703717
@override
718+
// ignore: avoid_dynamic_calls
704719
apply(left, right) => left > right;
705720
}
706721

@@ -717,6 +732,7 @@ class GreaterEqualOperation extends RelationalNumOperation {
717732
bool foldNums(num left, num right) => left >= right;
718733

719734
@override
735+
// ignore: avoid_dynamic_calls
720736
apply(left, right) => left >= right;
721737
}
722738

@@ -823,6 +839,7 @@ class CodeUnitAtOperation implements BinaryOperation {
823839
}
824840

825841
@override
842+
// ignore: avoid_dynamic_calls
826843
apply(left, right) => left.codeUnitAt(right);
827844
}
828845

pkg/compiler/lib/src/dart2js.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class OptionHandler {
4444
final bool multipleArguments;
4545

4646
void handle(argument) {
47+
// ignore: avoid_dynamic_calls
4748
(_handle as dynamic)(argument);
4849
}
4950

pkg/compiler/lib/src/deferred_load/deferred_load.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ class DeferredLoadTask extends CompilerTask {
585585
var element = d.entity;
586586
var elements = elementMap.putIfAbsent(importSet.unit!, () => []);
587587
var id = element.name ?? '$element';
588+
// ignore: avoid_dynamic_calls
588589
var context = (element as dynamic).memberContext.name;
589590
id = element.name == null || element.name == '' ? '<anonymous>' : id;
590591
id = '$context.$id';

pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ class ProgramBuilder {
794794
(DartType type, String? name, ConstantValue? defaultValue) {
795795
if (parameterStructure.namedParameters.contains(name)) {
796796
assert(defaultValue != null);
797+
// ignore: avoid_dynamic_calls
797798
optionalParameterDefaultValues[name] = defaultValue;
798799
}
799800
});
@@ -803,6 +804,7 @@ class ProgramBuilder {
803804
_elementEnvironment.forEachParameter(method,
804805
(DartType type, String? name, ConstantValue? defaultValue) {
805806
if (index >= parameterStructure.requiredPositionalParameters) {
807+
// ignore: avoid_dynamic_calls
806808
optionalParameterDefaultValues.add(defaultValue);
807809
}
808810
index++;

pkg/compiler/lib/src/kernel/kernel_world.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class KClosedWorld implements BuiltWorld {
165165
bool isMemberUsed(MemberEntity member) => liveMemberUsage.containsKey(member);
166166

167167
@override
168-
void forEachGenericMethod(Function f) {
168+
void forEachGenericMethod(void Function(FunctionEntity e) f) {
169169
liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) {
170170
if (member is FunctionEntity &&
171171
elementEnvironment.getFunctionTypeVariables(member).isNotEmpty) {
@@ -175,7 +175,7 @@ class KClosedWorld implements BuiltWorld {
175175
}
176176

177177
@override
178-
void forEachGenericInstanceMethod(Function f) {
178+
void forEachGenericInstanceMethod(void Function(FunctionEntity e) f) {
179179
liveMemberUsage.forEach((MemberEntity member, MemberUsage usage) {
180180
if (member is FunctionEntity &&
181181
member.isInstanceMember &&

pkg/compiler/lib/src/serialization/binary_sink.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class BinaryDataSink implements DataSink {
7272

7373
@override
7474
void writeEnum(dynamic value) {
75+
// ignore: avoid_dynamic_calls
7576
writeInt(value.index);
7677
}
7778

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ class SsaSimplifyInterceptors extends HBaseVisitor<bool>
8484
// possible that all uses can be rewritten to use different constants.
8585

8686
HInstruction constant = tryComputeConstantInterceptor(
87-
invoke.inputs[1], interceptor.interceptedClasses);
87+
// ignore: avoid_dynamic_calls
88+
invoke.inputs[1],
89+
// ignore: avoid_dynamic_calls
90+
interceptor.interceptedClasses);
8891
if (constant != null) {
8992
invoke.changeUse(interceptor, constant);
9093
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ class TargetJumpHandler implements JumpHandler {
133133
}
134134

135135
@override
136-
void forEachBreak(Function action) {
136+
void forEachBreak(
137+
void Function(HBreak instruction, LocalsHandler locals) action) {
137138
for (_JumpHandlerEntry entry in jumps) {
138139
if (entry.isBreak()) action(entry.jumpInstruction, entry.locals);
139140
}
140141
}
141142

142143
@override
143-
void forEachContinue(Function action) {
144+
void forEachContinue(
145+
void Function(HContinue instruction, LocalsHandler locals) action) {
144146
for (_JumpHandlerEntry entry in jumps) {
145147
if (entry.isContinue()) action(entry.jumpInstruction, entry.locals);
146148
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SsaTypePropagator extends HBaseVisitor<AbstractValue>
3535
implements OptimizationPhase {
3636
final Map<int, HInstruction> workmap = {};
3737
final List<int> worklist = [];
38-
final Map<HInstruction, Function> pendingOptimizations = {};
38+
final Map<HInstruction, void Function()> pendingOptimizations = {};
3939

4040
final GlobalTypeInferenceResults results;
4141
final CommonElements commonElements;

0 commit comments

Comments
 (0)