Skip to content

Commit

Permalink
Enable strict-inference (#46062)
Browse files Browse the repository at this point in the history
Avoids that dynamic accidentally sneaks in, see https://dart.dev/tools/analysis#enabling-additional-type-checks
  • Loading branch information
goderbauer authored Sep 19, 2023
1 parent a96f26f commit a7af55c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
errors:
# allow self-reference to deprecated members (we do this because otherwise we have
Expand Down
2 changes: 1 addition & 1 deletion ci/bin/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Future<String> _runGit(
return result.stdout;
}

typedef MessageCallback = Function(String? message, {MessageType type});
typedef MessageCallback = void Function(String? message, {MessageType type});

/// Base class for format checkers.
///
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ bool _onError(Object error, StackTrace? stackTrace) {
return PlatformDispatcher.instance._dispatchError(error, stackTrace ?? StackTrace.empty);
}

// ignore: always_declare_return_types, prefer_generic_function_type_aliases
typedef _ListStringArgFunction(List<String> args);
typedef _ListStringArgFunction = Object? Function(List<String> args);

@pragma('vm:entry-point')
void _runMain(Function startMainIsolateFunction,
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/test/canvaskit/surface_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void testMain() {
'getExtension',
<String>['WEBGL_lose_context'],
);
js_util.callMethod(loseContextExtension, 'loseContext', const <void>[]);
js_util.callMethod<void>(loseContextExtension, 'loseContext', const <void>[]);

// Pump a timer to allow the "lose context" event to propagate.
await Future<void>.delayed(Duration.zero);
Expand All @@ -160,7 +160,7 @@ void testMain() {
expect(isContextLost, isTrue);

// Emulate WebGL context restoration.
js_util.callMethod(loseContextExtension, 'restoreContext', const <void>[]);
js_util.callMethod<void>(loseContextExtension, 'restoreContext', const <void>[]);

// Pump a timer to allow the "restore context" event to propagate.
await Future<void>.delayed(Duration.zero);
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/test/engine/pointer_binding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3606,7 +3606,7 @@ mixin _ButtonedEventMixin on _BasicEventContext {
});
// timeStamp can't be set in the constructor, need to override the getter.
if (timeStamp != null) {
js_util.callMethod(
js_util.callMethod<void>(
objectConstructor,
'defineProperty',
<dynamic>[
Expand Down
2 changes: 1 addition & 1 deletion testing/scenario_app/bin/utils/logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ String _red = _supportsAnsi ? '\u001b[31m' : '';
String _gray = _supportsAnsi ? '\u001b[90m' : '';
String _reset = _supportsAnsi? '\u001B[0m' : '';

Future<void> step(String msg, Function() fn) async {
Future<void> step(String msg, Future<void> Function() fn) async {
stdout.writeln('-> $_green$msg$_reset');
try {
await fn();
Expand Down

0 comments on commit a7af55c

Please sign in to comment.