forked from firka/flutter
Enable strict-inference (#135043)
Avoids that dynamic accidentally sneaks in, see https://dart.dev/tools/analysis#enabling-additional-type-checks
This commit is contained in:
committed by
GitHub
parent
96a4ae9dc5
commit
b0a90aee17
@@ -11,7 +11,7 @@ library dart.ui;
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyStringBuffer {
|
||||
/// error; // error (missing_const_final_var_or_type, always_specify_types)
|
||||
/// error; // error (prefer_typing_uninitialized_variables, inference_failure_on_uninitialized_variable, missing_const_final_var_or_type)
|
||||
///
|
||||
/// StringBuffer _buffer = StringBuffer(); // error (prefer_final_fields, unused_field)
|
||||
/// }
|
||||
|
||||
@@ -16,6 +16,6 @@ String? bar;
|
||||
|
||||
/// error: widgets library was not imported (not even implicitly).
|
||||
/// ```dart
|
||||
/// print(Widget);
|
||||
/// print(Widget); // error (undefined_identifier)
|
||||
/// ```
|
||||
String? foo;
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
/// Widget build(BuildContext context) {
|
||||
/// final String title;
|
||||
/// return Opacity(
|
||||
/// key: globalKey, // error (undefined_identifier, argument_type_not_assignable)
|
||||
/// key: globalKey, // error (undefined_identifier)
|
||||
/// opacity: _visible ? 1.0 : 0.0,
|
||||
/// child: Text(title), // error (read_potentially_unassigned_final)
|
||||
/// );
|
||||
@@ -144,13 +144,14 @@
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// import 'dart:io'; // error (unused_import)/// final Widget p = Placeholder(); // error (undefined_class, undefined_function)
|
||||
/// import 'dart:io'; // error (unused_import)
|
||||
/// final Widget p = Placeholder(); // error (undefined_class, undefined_function)
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// // (e.g. in a stateful widget)
|
||||
/// void initState() { // error (must_call_super, annotate_overrides)
|
||||
/// widget.toString(); // error (undefined_identifier, return_of_invalid_type)
|
||||
/// widget.toString();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
||||
@@ -21,16 +21,19 @@ const List<String> expectedMainErrors = <String>[
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:134:14: (top-level declaration) (undefined_identifier)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:136:21: (top-level declaration) (read_potentially_unassigned_final)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:147:12: (self-contained program) (unused_import)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:152:10: (stateful widget) (annotate_overrides)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:152:10: (stateful widget) (must_call_super)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:160:7: (top-level declaration) (undefined_identifier)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:164: Found "```" in code but it did not match RegExp: pattern=^ */// *```dart\$ flags= so something is wrong. Line was: "/// ```"',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:148:11: (self-contained program) (undefined_class)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:148:22: (self-contained program) (undefined_function)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:153:10: (stateful widget) (annotate_overrides)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:153:10: (stateful widget) (must_call_super)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:161:7: (top-level declaration) (undefined_identifier)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/known_broken_documentation.dart:165: Found "```" in code but it did not match RegExp: pattern=^ */// *```dart\$ flags= so something is wrong. Line was: "/// ```"',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/short_but_still_broken.dart:9:12: (statement) (invalid_assignment)',
|
||||
'dev/bots/test/analyze-snippet-code-test-input/short_but_still_broken.dart:18:4: Empty ```dart block in snippet code.',
|
||||
];
|
||||
|
||||
const List<String> expectedUiErrors = <String>[
|
||||
'dev/bots/test/analyze-snippet-code-test-dart-ui/ui.dart:14:7: (top-level declaration) (prefer_typing_uninitialized_variables)',
|
||||
'dev/bots/test/analyze-snippet-code-test-dart-ui/ui.dart:14:7: (top-level declaration) (inference_failure_on_uninitialized_variable)',
|
||||
'dev/bots/test/analyze-snippet-code-test-dart-ui/ui.dart:14:7: (top-level declaration) (missing_const_final_var_or_type)',
|
||||
'dev/bots/test/analyze-snippet-code-test-dart-ui/ui.dart:16:20: (top-level declaration) (prefer_final_fields)',
|
||||
'dev/bots/test/analyze-snippet-code-test-dart-ui/ui.dart:16:20: (top-level declaration) (unused_field)',
|
||||
@@ -69,7 +72,7 @@ void main() {
|
||||
final List<String> stderrNoDescriptions = stderrLines.map(removeLintDescriptions).toList();
|
||||
expect(stderrNoDescriptions, <String>[
|
||||
...expectedMainErrors,
|
||||
'Found 16 snippet code errors.',
|
||||
'Found 18 snippet code errors.',
|
||||
'See the documentation at the top of dev/bots/analyze_snippet_code.dart for details.',
|
||||
'', // because we end with a newline, split gives us an extra blank line
|
||||
]);
|
||||
@@ -93,7 +96,7 @@ void main() {
|
||||
expect(stderrNoDescriptions, <String>[
|
||||
...expectedUiErrors,
|
||||
...expectedMainErrors,
|
||||
'Found 20 snippet code errors.',
|
||||
'Found 23 snippet code errors.',
|
||||
'See the documentation at the top of dev/bots/analyze_snippet_code.dart for details.',
|
||||
'', // because we end with a newline, split gives us an extra blank line
|
||||
]);
|
||||
|
||||
@@ -170,7 +170,7 @@ void main() {
|
||||
await expectLater(
|
||||
() async {
|
||||
final Future<void> rollFuture = autoroller.roll();
|
||||
await controller.stream.drain();
|
||||
await controller.stream.drain<Object?>();
|
||||
await rollFuture;
|
||||
},
|
||||
throwsA(isA<Exception>().having(
|
||||
@@ -214,7 +214,7 @@ void main() {
|
||||
], stdout: '[{"number": 123}]'),
|
||||
]);
|
||||
final Future<void> rollFuture = autoroller.roll();
|
||||
await controller.stream.drain();
|
||||
await controller.stream.drain<Object?>();
|
||||
await rollFuture;
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
expect(stdio.stdout, contains('flutter-pub-roller-bot already has open tool PRs'));
|
||||
@@ -312,7 +312,7 @@ void main() {
|
||||
]),
|
||||
]);
|
||||
final Future<void> rollFuture = autoroller.roll();
|
||||
await controller.stream.drain();
|
||||
await controller.stream.drain<Object?>();
|
||||
await rollFuture;
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ const String _activityName = 'MainActivity';
|
||||
const int _numberOfIterations = 10;
|
||||
|
||||
Future<void> _withApkInstall(
|
||||
String apkPath, String bundleName, Function(AndroidDevice) body) async {
|
||||
String apkPath, String bundleName, Future<void> Function(AndroidDevice) body) async {
|
||||
final DeviceDiscovery devices = DeviceDiscovery();
|
||||
final AndroidDevice device = await devices.workingDevice as AndroidDevice;
|
||||
await device.unlock();
|
||||
|
||||
@@ -42,7 +42,7 @@ Future<void> runTasks(
|
||||
List<String>? taskArgs,
|
||||
bool useEmulator = false,
|
||||
@visibleForTesting Map<String, String>? isolateParams,
|
||||
@visibleForTesting Function(String) print = print,
|
||||
@visibleForTesting void Function(String) print = print,
|
||||
@visibleForTesting List<String>? logs,
|
||||
}) async {
|
||||
for (final String taskName in taskNames) {
|
||||
|
||||
@@ -201,7 +201,7 @@ class _ZOrderTestPageState extends State<ZOrderTestPage> {
|
||||
)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return const SizedBox(
|
||||
|
||||
Reference in New Issue
Block a user