[lints] address diagnostics related to strict_top_level_inference

Change-Id: I228058202855900f0adba73c1ab04d35180a6e5d
Tested: this is an analyzer diagnostic only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414900
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Devon Carew
2025-03-17 08:27:57 -07:00
committed by Commit Queue
parent 2337553259
commit 3c973fb292
78 changed files with 134 additions and 104 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ vars = {
### /third_party/pkg dependencies
# 'tools/rev_sdk_deps.dart' will rev pkg dependencies to their latest; put an
# EOL comment after a dependency to instead pin at the current revision.
"core_rev": "15c7fe9958b95998ba2f5a4ad1beab66b9d815fb",
"core_rev": "9f4321008457d16674c0faabfe49327a2bb0cd29",
"dartdoc_rev": "c41b86b98ca935ec3c29cdb04cb190df30afb242",
"ecosystem_rev": "a3cc42d999acc95af96a48d155d7749d92cecb92",
"flute_rev": "e4ea0459a7debae5e9592c85141707b01fac86c9",
@@ -130,7 +130,7 @@ abstract class DartLanguageServerBenchmark {
}
}
void _checkLongRunningRequests(timer) {
void _checkLongRunningRequests(Timer timer) {
bool reportedSomething = false;
for (MapEntry<int, OutstandingRequest> waitingFor
in _outstandingRequestsWithId.entries) {
+3
View File
@@ -35,6 +35,9 @@ analyzer:
# About 30 violations of this in lib/.
provide_deprecation_message: ignore
# ~3,500 violations in test/.
strict_top_level_inference: ignore
# Ignoring this for all developers means developers don't need to ignore
# TODOs in their IDE settings.
todo: ignore
@@ -38,7 +38,7 @@ Matcher isMapOf(Matcher keyMatcher, Matcher valueMatcher) =>
Matcher isOneOf(List<Matcher> choiceMatchers) => _OneOf(choiceMatchers);
/// Assert that [actual] matches [matcher].
void outOfTestExpect(actual, Matcher matcher,
void outOfTestExpect(dynamic actual, Matcher matcher,
{String? reason, skip, bool verbose = false}) {
var matchState = {};
try {
@@ -49,8 +49,8 @@ void outOfTestExpect(actual, Matcher matcher,
fail(_defaultFailFormatter(actual, matcher, reason, matchState, verbose));
}
String _defaultFailFormatter(
actual, Matcher matcher, String? reason, Map matchState, bool verbose) {
String _defaultFailFormatter(dynamic actual, Matcher matcher, String? reason,
Map matchState, bool verbose) {
var description = StringDescription();
description.add('Expected: ').addDescriptionOf(matcher).add('\n');
description.add(' Actual: ').addDescriptionOf(actual).add('\n');
@@ -306,7 +306,7 @@ class MatchesJsonObject extends _RecursiveMatcher {
description.add(this.description);
@override
void populateMismatches(item, List<MismatchDescriber> mismatches) {
void populateMismatches(dynamic item, List<MismatchDescriber> mismatches) {
if (item is! Map) {
mismatches.add(simpleDescription('is not a map'));
return;
@@ -344,7 +344,7 @@ class MatchesJsonObject extends _RecursiveMatcher {
/// Check the type of a field called [key], having value [value], using
/// [valueMatcher]. If it doesn't match, record a closure in [mismatches]
/// which can describe the mismatch.
void _checkField(String key, value, Matcher valueMatcher,
void _checkField(String key, Object? value, Matcher valueMatcher,
List<MismatchDescriber> mismatches) {
checkSubstructure(
value,
@@ -757,7 +757,7 @@ abstract class _RecursiveMatcher extends Matcher {
/// the mismatch. [describeSubstructure] is used to describe which
/// substructure did not match.
void checkSubstructure(
item,
Object? item,
Matcher matcher,
List<MismatchDescriber> mismatches,
Description Function(Description description) describeSubstructure) {
@@ -806,7 +806,7 @@ abstract class _RecursiveMatcher extends Matcher {
}
@override
bool matches(item, Map matchState) {
bool matches(dynamic item, Map matchState) {
var mismatches = <MismatchDescriber>[];
populateMismatches(item, mismatches);
if (mismatches.isEmpty) {
@@ -819,7 +819,7 @@ abstract class _RecursiveMatcher extends Matcher {
/// Populate [mismatches] with descriptions of all the ways in which [item]
/// does not match.
void populateMismatches(item, List<MismatchDescriber> mismatches);
void populateMismatches(dynamic item, List<MismatchDescriber> mismatches);
/// Create a [MismatchDescriber] describing a mismatch with a simple string.
MismatchDescriber simpleDescription(String description) =>
@@ -14,7 +14,7 @@ import 'package:test/test.dart';
var root = Uri.parse('org-dartlang-test:///');
main() {
void main() {
late MemoryFileSystem memoryFs;
late MultiRootFileSystem multiRoot;
@@ -9,7 +9,7 @@ import 'package:front_end/src/api_unstable/build_integration.dart';
import 'package:front_end/src/api_prototype/memory_file_system.dart';
import 'package:test/test.dart';
main() {
void main() {
var root = Uri.parse('org-dartlang-test:///');
var fileSystem = SingleRootFileSystem(
'single-root', root.resolve('A/B'), MemoryFileSystem(root));
+5
View File
@@ -3,3 +3,8 @@
# BSD-style license that can be found in the LICENSE file.
include: package:lints/core.yaml
analyzer:
errors:
# ~75 violations in test/.
strict_top_level_inference: ignore
+1 -1
View File
@@ -13,7 +13,7 @@ Usage: dump_bytecode input.bytecode
Dumps bytecode file.
''';
main(List<String> arguments) async {
void main(List<String> arguments) async {
if (arguments.length != 1) {
print(_usage);
exit(1);
@@ -3999,7 +3999,7 @@ class BytecodeGenerator extends RecursiveVisitor {
return locals.tempIndexInFrame(node, tempIndex: 1);
}
_saveContextForTryBlock(TreeNode node) {
void _saveContextForTryBlock(TreeNode node) {
if (!locals.hasContextVar) {
return;
}
@@ -4007,7 +4007,7 @@ class BytecodeGenerator extends RecursiveVisitor {
asm.emitPopLocal(_savedContextVar(node));
}
_restoreContextForTryBlock(TreeNode node) {
void _restoreContextForTryBlock(TreeNode node) {
if (!locals.hasContextVar) {
return;
}
+1 -1
View File
@@ -124,7 +124,7 @@ class BytecodeDisassembler {
}
}
_decodeUint32At(int pos) =>
int _decodeUint32At(int pos) =>
_bytecode[pos] +
(_bytecode[pos + 1] << 8) +
(_bytecode[pos + 2] << 16) +
+2 -2
View File
@@ -436,13 +436,13 @@ class _ScopeBuilder extends RecursiveVisitor {
_loopDepth = saveLoopDepth;
}
_enterFrame(TreeNode node) {
void _enterFrame(TreeNode node) {
_currentFrameInternal = new Frame(node, _currentFrameInternal);
_enterScope(node);
_currentFrame.topScope = _currentScope;
}
_leaveFrame() {
void _leaveFrame() {
_leaveScope();
_currentFrameInternal = _currentFrame.parent;
}
+1 -1
View File
@@ -63,7 +63,7 @@ class Table {
/// Add an entry in the table, creating a new row each time [totalColumns]
/// entries are added.
void addEntry(entry) {
void addEntry(Object entry) {
if (_currentRow == null) {
_sealed = true;
_currentRow = [];
+1 -1
View File
@@ -149,7 +149,7 @@ String? libraryGroupName(Info info) {
}
/// Produce a string containing [value] padded with white space up to [n] chars.
String pad(value, n, {bool right = false}) {
String pad(Object value, int n, {bool right = false}) {
var s = '$value';
if (s.length >= n) return s;
// ignore: avoid_dynamic_calls
@@ -165,7 +165,7 @@ class _FrameDecoder implements Iterator<String> {
}
}
_extractMinifiedNames(
void _extractMinifiedNames(
String encodedInput,
SingleMapping sourceMap,
Map<String, String> minifiedNames,
+2 -1
View File
@@ -56,7 +56,8 @@ class DownloadedFileProvider extends CachingFileProvider {
class Logger {
final Set<String> _seenMessages = <String>{};
log(String message) {
void log(String message) {
if (_seenMessages.add(message)) {
print(message);
}
+6 -6
View File
@@ -87,24 +87,24 @@ class MultiValueOption<T> extends Option<List<T>> {
}
class IntMultiOption extends MultiValueOption<int> {
IntMultiOption(
name, void Function(WasmCompilerOptions o, List<int> v) applyToOptions,
IntMultiOption(String name,
void Function(WasmCompilerOptions o, List<int> v) applyToOptions,
{Iterable<String>? defaultsTo})
: super(name, applyToOptions, (v) => int.parse(v),
defaultsTo: defaultsTo);
}
class StringMultiOption extends MultiValueOption<String> {
StringMultiOption(
name, void Function(WasmCompilerOptions o, List<String> v) applyToOptions,
StringMultiOption(String name,
void Function(WasmCompilerOptions o, List<String> v) applyToOptions,
{String? abbr, Iterable<String>? defaultsTo})
: super(name, applyToOptions, (v) => v,
abbr: abbr, defaultsTo: defaultsTo);
}
class UriMultiOption extends MultiValueOption<Uri> {
UriMultiOption(
name, void Function(WasmCompilerOptions o, List<Uri> v) applyToOptions,
UriMultiOption(String name,
void Function(WasmCompilerOptions o, List<Uri> v) applyToOptions,
{Iterable<String>? defaultsTo})
: super(name, applyToOptions, (v) => Uri.file(Directory(v).absolute.path),
defaultsTo: defaultsTo);
+5
View File
@@ -1,5 +1,10 @@
include: package:lints/recommended.yaml
analyzer:
errors:
# ~40 violations in test/.
strict_top_level_inference: ignore
linter:
rules:
- directives_ordering
+1 -1
View File
@@ -3046,7 +3046,7 @@ class _DdsCapabilities {
/// `postEvent`.
bool get supportsCustomStreams => _isAtLeast(major: 1, minor: 4);
bool _isAtLeast({required major, required minor}) {
bool _isAtLeast({required int major, required int minor}) {
if (this.major > major) {
return true;
} else if (this.major == major && this.minor >= minor) {
+1 -1
View File
@@ -45,7 +45,7 @@ class DapHandler {
};
}
_handleEvent(Event event) {
void _handleEvent(Event event) {
if (event.event == 'initialized') {
_initializedCompleter.complete();
}
+2
View File
@@ -10,6 +10,8 @@ analyzer:
constant_identifier_names: ignore
implementation_imports: ignore
prefer_void_to_null: ignore
# ~5 violations in test/sourcemap.
strict_top_level_inference: ignore
exclude:
- doc/api/**
- gen/**
+2 -2
View File
@@ -323,7 +323,7 @@ abstract class Node {
/// Returns a node equivalent to [this], but with new source position and end
/// source position.
T _withSourceInformation<T extends Node>(
sourceInformation, T Function() cloneFunc) {
Object? sourceInformation, T Function() cloneFunc) {
if (sourceInformation == this.sourceInformation) {
return this as T;
}
@@ -334,7 +334,7 @@ abstract class Node {
return clone;
}
Node withSourceInformation(sourceInformation) =>
Node withSourceInformation(Object? sourceInformation) =>
_withSourceInformation(sourceInformation, _clone);
bool get isCommaOperator => false;
@@ -158,7 +158,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
}
static Instantiator<T> same<T extends Node>(T node) => (arguments) => node;
static Null makeNull(arguments) => null;
static Null makeNull(dynamic arguments) => null;
Instantiator visit<T extends Node>(T node) {
if (forceCopy || analysis.containsInterpolatedNodes(node)) {
@@ -6,7 +6,7 @@ import 'dart:io';
import 'package:dynamic_modules/dynamic_modules.dart' show loadModuleFromBytes;
main(List<String> args) {
Future<void> main(List<String> args) {
final bytes = File(args[0]).readAsBytesSync();
return loadModuleFromBytes(bytes);
}
@@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
import 'shared/shared.dart' show M;
/// A dynamic module can apply an exposed mixin.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as M;
Expect.equals(3, o.method1());
Expect.equals('*3 2', o.method2());
@@ -7,7 +7,7 @@ import 'package:expect/expect.dart';
import 'shared/shared.dart' as shared;
main() async {
void main() async {
await helper.load('entry1.dart');
Expect.equals('dynamic module 1: hello', shared.topLevelClosure!('hello'));
helper.done();
@@ -6,7 +6,7 @@ import '../../common/testing.dart' as helper;
import 'package:expect/expect.dart';
/// A dynamic module can use core libraries and language features.
main() async {
void main() async {
final result = await helper.load('entry1.dart');
Expect.isTrue(result);
helper.done();
@@ -7,7 +7,7 @@ import 'package:expect/async_helper.dart' show asyncExpectThrows;
// It is an error to load a module that provides a second definition for
// a library that already exists in the application.
main() async {
void main() async {
await helper.load('entry1.dart');
await asyncExpectThrows(helper.load('entry2.dart'));
helper.done();
@@ -9,7 +9,7 @@ import 'shared/shared.dart' show Base;
/// A dynamic module is allowed to extend a class in the dynamic interface and
/// override its members.
main() async {
void main() async {
Expect.equals(100, Base().method1(0));
final o1 = (await helper.load('entry1.dart'));
final o2 = (await helper.load('entry2.dart'));
@@ -9,7 +9,7 @@ import 'shared/shared.dart' show Base;
/// A dynamic module is allowed to extend a class in the dynamic interface and
/// override its members.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as Base;
Expect.equals(1, o.method1());
Expect.equals(2, o.method2());
@@ -18,7 +18,7 @@ class Child extends Base {
/// This is similar to the `extend_class` test case, but includes more nuance,
/// like extending a non-leaf class that already was used in the program, since
/// that may affect dispatch logic based on some backends.
main() async {
void main() async {
Base o = Child1();
Expect.equals(1, o.method1());
Expect.equals(3, o.method2());
@@ -7,7 +7,7 @@ import 'package:expect/expect.dart';
/// A dynamic module is allowed to extend a class in the dynamic interface and
/// override its members.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as int;
Expect.equals(1, o);
helper.done();
@@ -9,7 +9,7 @@ import 'shared/shared.dart' show Base, SuperBase;
/// A dynamic module is allowed to extend a class in the dynamic interface and
/// override its members.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as Base;
if (o is SuperBase<num, String>) {
Expect.equals(3, o.method1());
@@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
import 'shared/shared.dart' show Base;
/// A dynamic module can implement an exposed class.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as Base;
Expect.equals(3, o.method1());
Expect.equals(4, o.method2());
@@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
import 'shared/shared.dart' show Base;
/// A dynamic module can implement an exposed class.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as Base;
Expect.equals(5, o.method1());
Expect.equals(6, o.method2());
@@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
import 'shared/shared.dart';
/// A dynamic module can implement an exposed class.
main() async {
void main() async {
final o = await helper.load('entry1.dart') as Triple;
Expect.equals(3, o.e.method3());
Expect.equals(2, o.i1.method1());
@@ -7,7 +7,7 @@ import 'package:expect/async_helper.dart' show asyncExpectThrows;
/// For the same reasons as the `duplicate_library` test, it is an error to load
/// the same module twice.
main() async {
void main() async {
await helper.load('entry1.dart');
await asyncExpectThrows(helper.load('entry1.dart'));
helper.done();
@@ -8,7 +8,7 @@ import '../../common/testing.dart' as helper;
import 'package:expect/expect.dart';
/// Dynamic module can be loaded from unmodifiable view.
main() async {
void main() async {
final result = await helper.load('entry1.dart',
transformBytes: (Uint8List bytes) => bytes.buffer
.asUint8List(0, bytes.lengthInBytes)
@@ -7,7 +7,7 @@ import 'package:expect/expect.dart';
import '../../common/testing.dart' as helper;
import 'modules/common.dart';
main() async {
void main() async {
final a1 = await helper.load('entry1.dart') as A;
final a2 = await helper.load('entry2.dart') as A;
Expect.equals(a1.getString(), 'B');
@@ -9,7 +9,7 @@ import 'shared/shared.dart' show Base;
/// A dynamic module is allowed to extend a class in the dynamic interface and
/// override its members.
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as Base;
Expect.equals(1, o.method1(1));
helper.done();
@@ -6,7 +6,7 @@ import '../../common/testing.dart' as helper;
import 'shared/shared.dart' show A, B;
main() async {
void main() async {
final o = (await helper.load('entry1.dart')) as A;
final l = <dynamic>[A(), B()];
for (final entry in l) {
@@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
// Similar to `isolated_shared`, constant canonicalization distinguishes
// two constnats, even if they are created from a common library that was
// not part of the original application.
main() async {
void main() async {
final c1 = (await helper.load('entry1.dart'));
final c2 = (await helper.load('entry2.dart'));
@@ -13,7 +13,7 @@ class B {
// Similar to `isolated_shared`, constant canonicalization distinguishes
// two constnats, even if they are created from a common library that was
// not part of the original application.
main() async {
void main() async {
final c1 = (await helper.load('entry1.dart'));
final c2 = (await helper.load('entry2.dart'));
@@ -6,7 +6,7 @@ import '../../common/testing.dart' as helper;
import 'shared/shared.dart' show A, B, C;
main() async {
void main() async {
final c = await helper.load('entry1.dart') as C?;
if (c != null) {
A(B(c).c.foo);
@@ -8,7 +8,7 @@ import 'package:expect/expect.dart';
import 'shared/shared.dart' as shared;
/// A top-level setter can be invoked from a dynamic module.
main() async {
void main() async {
Expect.equals('original', shared.topLevelField);
Expect.equals(0, shared.topLevelGetterInternal);
Expect.equals(0, shared.topLevelSetterInternal);
+1 -1
View File
@@ -4,7 +4,7 @@
import "package:expect/expect.dart";
main() {
void main() {
var o1 = Object();
var o2 = Object();
var o3 = Object();
@@ -4,7 +4,7 @@
import 'package:heap_snapshot/intset.dart';
main() {
void main() {
for (int every in [16, 8, 4, 3, 2, 1]) {
iterationBenchmark(every, 1);
iterationBenchmark(every, 0.5);
+2 -2
View File
@@ -6,7 +6,7 @@ import 'dart:math';
import 'package:heap_snapshot/intset.dart';
main() {
void main() {
checkDump();
checkBounds();
handCodedTests();
@@ -15,7 +15,7 @@ main() {
print("OK");
}
void addExpectRangeError(set, int value) {
void addExpectRangeError(Set set, int value) {
try {
set.add(value);
throw "Expected RangeError";
+1 -1
View File
@@ -197,7 +197,7 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
}
static Instantiator same(Node node) => (arguments) => node;
static Null makeNull(arguments) => null;
static Null makeNull(dynamic arguments) => null;
Instantiator visit(Node node) {
if (forceCopy || analysis.containsInterpolatedNodes(node)) {
+3 -2
View File
@@ -209,7 +209,8 @@ Future<Module> _createSdkModule(Uri root) async {
}
/// Trim the set of modules, and detect cycles while we are at it.
_detectCyclesAndRemoveUnreachable(Map<String, Module> modules, Module main) {
void _detectCyclesAndRemoveUnreachable(
Map<String, Module> modules, Module main) {
Set<Module> visiting = {};
Set<Module> visited = {};
@@ -249,7 +250,7 @@ packages:
''';
/// Report an conflict error.
_moduleConflict(String name, Module existing, Uri root) {
Never _moduleConflict(String name, Module existing, Uri root) {
var isFile = name.endsWith('.dart');
var entryType = isFile ? 'file' : 'folder';
@@ -10,7 +10,7 @@ import 'package:modular_test/src/find_sdk_root.dart';
// This and the 'src/find_sdk_root2_test.dart' check that we can locate
// the SDK root properly regardless of the location of the `Platform.script`.
main() {
void main() {
asyncTest(() async {
Expect.equals(Platform.script.resolve("../../../"), await findRoot());
});
+1 -1
View File
@@ -11,7 +11,7 @@ import 'package:modular_test/src/io_pipeline.dart';
import 'pipeline_common.dart';
main() async {
void main() async {
var uri = Directory.systemTemp.uri.resolve("io_modular_test_root/");
int i = 0;
while (await Directory.fromUri(uri).exists()) {
@@ -13,7 +13,7 @@ import 'package:modular_test/src/suite.dart';
import 'package:args/args.dart';
main(List<String> args) async {
void main(List<String> args) async {
var options = _Options.parse(args);
var baseUri = Platform.script.resolve('./');
var baseDir = Directory.fromUri(baseUri);
@@ -11,7 +11,7 @@ import 'package:modular_test/src/memory_pipeline.dart';
import 'pipeline_common.dart';
main() {
void main() {
runPipelineTest(MemoryPipelineTestStrategy());
}
+2 -1
View File
@@ -91,7 +91,8 @@ abstract class PipelineTestStrategy<S extends ModularStep> {
FutureOr<void> cleanup(Pipeline<S> pipeline);
}
runPipelineTest<S extends ModularStep>(PipelineTestStrategy<S> testStrategy) {
void runPipelineTest<S extends ModularStep>(
PipelineTestStrategy<S> testStrategy) {
var sources = {
testStrategy.testRootUri.resolve("a1.dart"): 'A1',
testStrategy.testRootUri.resolve("a2.dart"): 'A2',
@@ -5,7 +5,7 @@
import 'package:test/test.dart';
import 'package:modular_test/src/test_specification_parser.dart';
main() {
void main() {
test('require dependencies section', () {
expect(() => parseTestSpecification(""),
throwsA(TypeMatcher<InvalidSpecificationError>()));
@@ -10,7 +10,7 @@ import 'package:modular_test/src/find_sdk_root.dart';
// This and the '../find_sdk_root1_test.dart' check that we can locate
// the SDK root properly regardless of the location of the `Platform.script`.
main() {
void main() {
asyncTest(() async {
Expect.equals(Platform.script.resolve("../../../../"), await findRoot());
});
@@ -9,7 +9,7 @@ import 'package:test/test.dart';
import 'package:modular_test/src/suite.dart';
import 'package:modular_test/src/pipeline.dart';
main() {
void main() {
test('no steps is OK', () {
validateSteps([]);
});
@@ -73,7 +73,7 @@ main() {
});
}
validateSteps(List<ModularStep> steps) {
void validateSteps(List<ModularStep> steps) {
_NoopPipeline(steps);
}
@@ -8,7 +8,7 @@ library;
import 'package:test/test.dart';
import 'package:modular_test/src/suite.dart';
main() {
void main() {
test('module test is not empty', () {
var m = Module("a", [], Uri.parse("app:/"), []);
expect(() => ModularTest([], m, []), throwsA(TypeMatcher<ArgumentError>()));
+1 -1
View File
@@ -80,7 +80,7 @@ void lintStdIn(
}
}
void lintPath(path,
void lintPath(String path,
{bool checkForDisjunctions = false, required bool checkForNonExisting}) {
var filesWithErrors = <String>[];
if (FileSystemEntity.isFileSync(path)) {
@@ -224,7 +224,7 @@ String formatComments(List<String> comments) {
return sb.toString();
}
main(List<String> arguments) async {
void main(List<String> arguments) async {
var parser = buildParser();
var results = parser.parse(arguments);
if (results["help"] || results.rest.isEmpty) {
+7 -5
View File
@@ -334,11 +334,13 @@ List<Expression> _difference(List<Expression> aList, List<Expression> bList) {
/// Finds the first occurrence of [expressionToFind] in [expressions] or
/// returns null.
TExpression? _findFirst<TExpression>(
expressionToFind, List<TExpression> expressions) {
return expressions.cast<TExpression?>().firstWhere(
(otherExpression) => expressionToFind.compareTo(otherExpression) == 0,
orElse: () => null);
T? _findFirst<T extends Expression>(T expressionToFind, List<T> expressions) {
for (var expr in expressions) {
if (expressionToFind.compareTo(expr) == 0) {
return expr;
}
}
return null;
}
/// Adds [expressionToAdd] to [expressions] if is not present.
+3 -2
View File
@@ -41,7 +41,8 @@ StatusFile createFromString(String text) {
return StatusFile.parse("test", text.split('\n'));
}
expectError(String text, String expectedError, {bool disjunctions = false}) {
void expectError(String text, String expectedError,
{bool disjunctions = false}) {
var statusFile = createFromString(text);
var errors = lint(statusFile,
checkForDisjunctions: disjunctions, checkForNonExisting: false)
@@ -49,7 +50,7 @@ expectError(String text, String expectedError, {bool disjunctions = false}) {
Expect.equals(expectedError, errors.first.toString());
}
expectNoError(String text, {bool disjunctions = true}) {
void expectNoError(String text, {bool disjunctions = true}) {
var errors = lint(createFromString(text),
checkForDisjunctions: disjunctions, checkForNonExisting: false)
.toList();
+1 -1
View File
@@ -16,7 +16,7 @@ import 'package:status_file/status_file_normalizer.dart';
final Uri statusFilePath = Platform.script.resolve("data/");
main() {
void main() {
sanityCheck();
normalizeCheck();
}
@@ -6,7 +6,7 @@ import "package:expect/expect.dart";
import "package:status_file/src/expression.dart";
import 'package:status_file/src/disjunctive.dart';
main() {
void main() {
testDnf();
}
@@ -21,10 +21,10 @@ class TestEnvironment implements Environment {
@override
String? lookUp(String name) => _values[name];
operator []=(String key, String value) => _values[key] = value;
void operator []=(String key, String value) => _values[key] = value;
}
main() {
void main() {
testExpression();
testSyntaxError();
testBoolean();
@@ -1146,7 +1146,7 @@ class BrowserTestingServer {
errorReportingServer.listen(errorReportingHandler, onError: errorHandler);
}
void setupDispatchingServer(_) {
void setupDispatchingServer(HttpServer _) {
var server = configuration.servers.server!;
void noCache(HttpRequest request) {
request.response.headers
+1 -1
View File
@@ -152,7 +152,7 @@ class TestingServers {
}
}
void _onError(e) {
void _onError(Object? e) {
DebugLogger.error('HttpServer: an error occurred', e);
}
@@ -6,7 +6,7 @@ import 'package:expect/expect.dart';
import 'package:test_runner/src/dependency_graph.dart';
main() {
void main() {
var graph = Graph<int>();
var numberOfEvents = 0;
var addEventAssertions = [];
+1 -1
View File
@@ -10,7 +10,7 @@ import 'dart:io';
import 'package:expect/expect.dart';
// SharedOptions=--enable-experiment=test-experiment
main() {
void main() {
Expect.isTrue(Platform.executableArguments
.contains("--enable-experiment=test-experiment"));
}
@@ -4,7 +4,7 @@
import 'dart:io';
main(List<String> arguments) {
void main(List<String> arguments) {
var outputFile = arguments[0];
var file = File(outputFile);
file.createSync();
+1 -1
View File
@@ -23,7 +23,7 @@ class TestController {
static int numCompletedTests = 0;
// Used as TestCase.completedCallback.
static processCompletedTest(TestCase testCase) {
static void processCompletedTest(TestCase testCase) {
final passed = testCase.result.canBeOutcomeOf(testCase.realExpected);
numCompletedTests++;
+4 -3
View File
@@ -347,13 +347,14 @@ abstract class Step<I, O, C extends ChainContext> {
Future<Result<O>> run(I input, C context);
Result<O> unhandledError(error, StackTrace trace) {
Result<O> unhandledError(Object? error, StackTrace trace) {
return Result<O>.crash(error, trace);
}
Result<O> pass(O output) => Result<O>.pass(output);
Result<O> crash(error, StackTrace trace) => Result<O>.crash(error, trace);
Result<O> crash(Object? error, StackTrace trace) =>
Result<O>.crash(error, trace);
Result<O> fail(O output, [error, StackTrace? trace]) {
return Result<O>.fail(output, error, trace);
@@ -392,7 +393,7 @@ class Result<O> {
Result.pass(O output) : this(output, Expectation.pass, null);
Result.crash(error, StackTrace trace)
Result.crash(Object? error, StackTrace trace)
: this(null, Expectation.crash, error, trace: trace);
Result.fail(O output, [error, StackTrace? trace])
+3 -3
View File
@@ -67,12 +67,12 @@ abstract class Logger {
void logSuiteComplete(Suite suite);
void logUncaughtError(error, StackTrace stackTrace);
void logUncaughtError(Object error, StackTrace stackTrace);
/// Issued when there's been a crash caught by the framework.
/// Notice that the exit-code has already been set and that the error has
/// been printed to stderr.
void noticeFrameworkCatchError(error, StackTrace stackTrace);
void noticeFrameworkCatchError(Object? error, StackTrace stackTrace);
}
class StdoutLogger implements Logger {
@@ -196,7 +196,7 @@ class StdoutLogger implements Logger {
}
@override
void logUncaughtError(error, StackTrace stackTrace) {
void logUncaughtError(Object error, StackTrace stackTrace) {
logMessage(error);
logMessage(stackTrace);
}
+5
View File
@@ -3,3 +3,8 @@
# BSD-style license that can be found in the LICENSE file.
include: package:lints/core.yaml
analyzer:
errors:
# ~50 violations in bin, lib, and test.
strict_top_level_inference: ignore
+1 -1
View File
@@ -13,7 +13,7 @@ Usage: list_libraries input.dill
Lists libraries included in a kernel binary file.
''';
main(List<String> arguments) async {
void main(List<String> arguments) async {
if (arguments.length != 1) {
print(_usage);
exit(1);
+2
View File
@@ -3,6 +3,8 @@ include: package:lints/recommended.yaml
analyzer:
errors:
unnecessary_library_name: ignore
# ~300 violations in test/.
strict_top_level_inference: ignore
linter:
rules:
+1 -1
View File
@@ -47,7 +47,7 @@ class Either2<T1, T2> extends ToJsonable {
String toString() => map((t) => t.toString(), (t) => t.toString());
/// Checks whether the value of the union equals the supplied value.
bool valueEquals(o) => map((t) => t == o, (t) => t == o);
bool valueEquals(Object o) => map((t) => t == o, (t) => t == o);
}
/// An object from the LSP/DAP specs that can be converted to JSON.
@@ -31,9 +31,9 @@ Object? specToJson(Object? obj) {
}
}
void _alwaysNull(_, [__]) {}
void _alwaysNull(dynamic _, [dynamic __]) {}
bool _alwaysTrue(_, [__]) => true;
bool _alwaysTrue(dynamic _, [dynamic __]) => true;
typedef DocumentChanges
= List<Either4<CreateFile, DeleteFile, RenameFile, TextDocumentEdit>>;
@@ -71,7 +71,7 @@ class Either2<T1, T2> implements ToJsonable {
String toString() => map((t) => t.toString(), (t) => t.toString());
/// Checks whether the value of the union equals the supplied value.
bool valueEquals(o) => map((t) => t == o, (t) => t == o);
bool valueEquals(Object o) => map((t) => t == o, (t) => t == o);
}
class Either3<T1, T2, T3> implements ToJsonable {
@@ -125,7 +125,8 @@ class Either3<T1, T2, T3> implements ToJsonable {
);
/// Checks whether the value of the union equals the supplied value.
bool valueEquals(o) => map((t) => t == o, (t) => t == o, (t) => t == o);
bool valueEquals(Object o) =>
map((t) => t == o, (t) => t == o, (t) => t == o);
}
class Either4<T1, T2, T3, T4> implements ToJsonable {
@@ -193,7 +194,7 @@ class Either4<T1, T2, T3, T4> implements ToJsonable {
);
/// Checks whether the value of the union equals the supplied value.
bool valueEquals(o) =>
bool valueEquals(Object o) =>
map((t) => t == o, (t) => t == o, (t) => t == o, (t) => t == o);
}