Commit 78db9656 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by Flutter GitHub Bot

Reland implicit-casts: false (#47431)

parent 4af66e33
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
analyzer: analyzer:
strong-mode: strong-mode:
implicit-casts: false
implicit-dynamic: false implicit-dynamic: false
errors: errors:
# treat missing required parameters as a warning (not a hint) # treat missing required parameters as a warning (not a hint)
......
...@@ -20,7 +20,7 @@ class FastScrollLargeImagesMemoryTest extends MemoryTest { ...@@ -20,7 +20,7 @@ class FastScrollLargeImagesMemoryTest extends MemoryTest {
); );
@override @override
AndroidDevice get device => super.device; AndroidDevice get device => super.device as AndroidDevice;
@override @override
int get iterationCount => 5; int get iterationCount => 5;
......
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:io' show File; import 'dart:io' show File;
import 'package:flutter/foundation.dart';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:flutter_driver/flutter_driver.dart';
import 'package:collection/collection.dart';
const String _kPathParent = 'test_driver/goldens/'; const String _kPathParent = 'test_driver/goldens/';
...@@ -43,8 +44,7 @@ class DriverScreenShotTester { ...@@ -43,8 +44,7 @@ class DriverScreenShotTester {
Future<bool> compareScreenshots(List<int> screenshot) async { Future<bool> compareScreenshots(List<int> screenshot) async {
final File file = File(_getImageFilePath()); final File file = File(_getImageFilePath());
final List<int> matcher = await file.readAsBytes(); final List<int> matcher = await file.readAsBytes();
final Function listEquals = const ListEquality<int>().equals; return listEquals<int>(screenshot, matcher);
return listEquals(screenshot, matcher);
} }
/// Returns a bytes representation of a screenshot on the current screen. /// Returns a bytes representation of a screenshot on the current screen.
......
...@@ -53,10 +53,10 @@ Future<void> main(List<String> arguments) async { ...@@ -53,10 +53,10 @@ Future<void> main(List<String> arguments) async {
exit(0); exit(0);
} }
final String arbPathString = results['arb-dir']; final String arbPathString = results['arb-dir'] as String;
final String outputFileString = results['output-localization-file']; final String outputFileString = results['output-localization-file'] as String;
final String templateArbFileName = results['template-arb-file']; final String templateArbFileName = results['template-arb-file'] as String;
final String classNameString = results['output-class']; final String classNameString = results['output-class'] as String;
const local.LocalFileSystem fs = local.LocalFileSystem(); const local.LocalFileSystem fs = local.LocalFileSystem();
final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs); final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs);
......
...@@ -214,10 +214,7 @@ const Set<String> allowableDateFormats = <String>{ ...@@ -214,10 +214,7 @@ const Set<String> allowableDateFormats = <String>{
's', 's',
}; };
bool _isDateParameter(dynamic placeholderValue) { bool _isDateParameter(Map<String, dynamic> placeholderValue) => placeholderValue['type'] == 'DateTime';
return placeholderValue is Map<String, dynamic> &&
placeholderValue['type'] == 'DateTime';
}
bool _dateParameterIsValid(Map<String, dynamic> placeholderValue, String placeholder) { bool _dateParameterIsValid(Map<String, dynamic> placeholderValue, String placeholder) {
if (allowableDateFormats.contains(placeholderValue['format'])) if (allowableDateFormats.contains(placeholderValue['format']))
...@@ -260,6 +257,7 @@ String generateDateFormattingLogic(Map<String, dynamic> bundle, String key) { ...@@ -260,6 +257,7 @@ String generateDateFormattingLogic(Map<String, dynamic> bundle, String key) {
for (String placeholder in placeholders.keys) { for (String placeholder in placeholders.keys) {
final dynamic value = placeholders[placeholder]; final dynamic value = placeholders[placeholder];
if ( if (
value is Map<String, dynamic> &&
_isDateParameter(value) && _isDateParameter(value) &&
_containsFormatKey(value, placeholder) && _containsFormatKey(value, placeholder) &&
_dateParameterIsValid(value, placeholder) _dateParameterIsValid(value, placeholder)
...@@ -291,6 +289,7 @@ List<String> genIntlMethodArgs(Map<String, dynamic> bundle, String key) { ...@@ -291,6 +289,7 @@ List<String> genIntlMethodArgs(Map<String, dynamic> bundle, String key) {
for (String placeholder in placeholders.keys) { for (String placeholder in placeholders.keys) {
final dynamic value = placeholders[placeholder]; final dynamic value = placeholders[placeholder];
if ( if (
value is Map<String, dynamic> &&
_isDateParameter(value) && _isDateParameter(value) &&
_containsFormatKey(value, placeholder) && _containsFormatKey(value, placeholder) &&
_dateParameterIsValid(value, placeholder) _dateParameterIsValid(value, placeholder)
...@@ -315,7 +314,7 @@ String genSimpleMethod(Map<String, dynamic> bundle, String key) { ...@@ -315,7 +314,7 @@ String genSimpleMethod(Map<String, dynamic> bundle, String key) {
final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>; final Map<String, dynamic> placeholders = attributesMap['placeholders'] as Map<String, dynamic>;
for (String placeholder in placeholders.keys) { for (String placeholder in placeholders.keys) {
final dynamic value = placeholders[placeholder]; final dynamic value = placeholders[placeholder];
if (_isDateParameter(value)) { if (value is Map<String, dynamic> && _isDateParameter(value)) {
message = message.replaceAll('{$placeholder}', '\$${placeholder}String'); message = message.replaceAll('{$placeholder}', '\$${placeholder}String');
} else { } else {
message = message.replaceAll('{$placeholder}', '\$$placeholder'); message = message.replaceAll('{$placeholder}', '\$$placeholder');
...@@ -599,8 +598,8 @@ class LocalizationsGenerator { ...@@ -599,8 +598,8 @@ class LocalizationsGenerator {
for (File file in fileSystemEntityList) { for (File file in fileSystemEntityList) {
final String filePath = file.path; final String filePath = file.path;
if (arbFilenameRE.hasMatch(filePath)) { if (arbFilenameRE.hasMatch(filePath)) {
final Map<String, dynamic> arbContents = json.decode(file.readAsStringSync()); final Map<String, dynamic> arbContents = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
String localeString = arbContents['@@locale']; String localeString = arbContents['@@locale'] as String;
if (localeString == null) { if (localeString == null) {
final RegExpMatch arbFileMatch = arbFilenameLocaleRE.firstMatch(filePath); final RegExpMatch arbFileMatch = arbFilenameLocaleRE.firstMatch(filePath);
if (arbFileMatch == null) { if (arbFileMatch == null) {
...@@ -653,7 +652,7 @@ class LocalizationsGenerator { ...@@ -653,7 +652,7 @@ class LocalizationsGenerator {
void generateClassMethods() { void generateClassMethods() {
Map<String, dynamic> bundle; Map<String, dynamic> bundle;
try { try {
bundle = json.decode(templateArbFile.readAsStringSync()); bundle = json.decode(templateArbFile.readAsStringSync()) as Map<String, dynamic>;
} on FileSystemException catch (e) { } on FileSystemException catch (e) {
throw FileSystemException('Unable to read input arb file: $e'); throw FileSystemException('Unable to read input arb file: $e');
} on FormatException catch (e) { } on FormatException catch (e) {
...@@ -669,7 +668,7 @@ class LocalizationsGenerator { ...@@ -669,7 +668,7 @@ class LocalizationsGenerator {
'Invalid key format: $key \n It has to be in camel case, cannot start ' 'Invalid key format: $key \n It has to be in camel case, cannot start '
'with a number, and cannot contain non-alphanumeric characters.' 'with a number, and cannot contain non-alphanumeric characters.'
); );
if (pluralValueRE.hasMatch(bundle[key])) if (pluralValueRE.hasMatch(bundle[key] as String))
classMethods.add(genPluralMethod(bundle, key)); classMethods.add(genPluralMethod(bundle, key));
else else
classMethods.add(genSimpleMethod(bundle, key)); classMethods.add(genSimpleMethod(bundle, key));
......
...@@ -314,7 +314,7 @@ class MouseTracker extends ChangeNotifier { ...@@ -314,7 +314,7 @@ class MouseTracker extends ChangeNotifier {
final int device = state.device; final int device = state.device;
return (_mouseStates.containsKey(device) && _trackedAnnotations.isNotEmpty) return (_mouseStates.containsKey(device) && _trackedAnnotations.isNotEmpty)
? LinkedHashSet<MouseTrackerAnnotation>.from(annotationFinder(globalPosition)) ? LinkedHashSet<MouseTrackerAnnotation>.from(annotationFinder(globalPosition))
: <MouseTrackerAnnotation>{}; : <MouseTrackerAnnotation>{} as LinkedHashSet<MouseTrackerAnnotation>;
} }
static bool get _duringBuildPhase { static bool get _duringBuildPhase {
......
...@@ -530,7 +530,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T ...@@ -530,7 +530,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
return _dragging == toAccept && toAccept != toWrap.key; return _dragging == toAccept && toAccept != toWrap.key;
}, },
onAccept: (Key accepted) { }, onAccept: (Key accepted) { },
onLeave: (Key leaving) { }, onLeave: (Object leaving) { },
); );
}); });
} }
......
...@@ -162,12 +162,12 @@ abstract class EdgeInsetsGeometry { ...@@ -162,12 +162,12 @@ abstract class EdgeInsetsGeometry {
/// or equal to `min`, and less than or equal to `max`. /// or equal to `min`, and less than or equal to `max`.
EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) { EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
return _MixedEdgeInsets.fromLRSETB( return _MixedEdgeInsets.fromLRSETB(
_left.clamp(min._left, max._left), _left.clamp(min._left, max._left) as double,
_right.clamp(min._right, max._right), _right.clamp(min._right, max._right) as double,
_start.clamp(min._start, max._start), _start.clamp(min._start, max._start) as double,
_end.clamp(min._end, max._end), _end.clamp(min._end, max._end) as double,
_top.clamp(min._top, max._top), _top.clamp(min._top, max._top) as double,
_bottom.clamp(min._bottom, max._bottom), _bottom.clamp(min._bottom, max._bottom) as double,
); );
} }
......
...@@ -672,9 +672,9 @@ class PlatformViewLayer extends Layer { ...@@ -672,9 +672,9 @@ class PlatformViewLayer extends Layer {
if (hoverAnnotation == null || !rect.contains(localPosition)) { if (hoverAnnotation == null || !rect.contains(localPosition)) {
return false; return false;
} }
if (MouseTrackerAnnotation == S) { if (S == MouseTrackerAnnotation) {
final Object untypedValue = hoverAnnotation; final Object untypedValue = hoverAnnotation;
final S typedValue = untypedValue; final S typedValue = untypedValue as S;
result.add(AnnotationEntry<S>( result.add(AnnotationEntry<S>(
annotation: typedValue, annotation: typedValue,
localPosition: localPosition, localPosition: localPosition,
......
...@@ -7,6 +7,7 @@ import 'dart:ui' as ui show Color; ...@@ -7,6 +7,7 @@ import 'dart:ui' as ui show Color;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'layer.dart';
import 'object.dart'; import 'object.dart';
import 'sliver.dart'; import 'sliver.dart';
...@@ -71,7 +72,7 @@ abstract class RenderProxySliver extends RenderSliver with RenderObjectWithChild ...@@ -71,7 +72,7 @@ abstract class RenderProxySliver extends RenderSliver with RenderObjectWithChild
@override @override
void applyPaintTransform(RenderObject child, Matrix4 transform) { void applyPaintTransform(RenderObject child, Matrix4 transform) {
assert(child != null); assert(child != null);
final SliverPhysicalParentData childParentData = child.parentData; final SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
childParentData.applyPaintTransform(transform); childParentData.applyPaintTransform(transform);
} }
} }
...@@ -169,7 +170,7 @@ class RenderSliverOpacity extends RenderProxySliver { ...@@ -169,7 +170,7 @@ class RenderSliverOpacity extends RenderProxySliver {
offset, offset,
_alpha, _alpha,
_paintWithOpacity, _paintWithOpacity,
oldLayer: layer, oldLayer: layer as OpacityLayer,
); );
} }
} }
......
...@@ -332,7 +332,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB ...@@ -332,7 +332,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
registerServiceExtension( registerServiceExtension(
name: 'fastReassemble', name: 'fastReassemble',
callback: (Map<String, Object> params) async { callback: (Map<String, Object> params) async {
final String className = params['class']; final String className = params['class'] as String;
void markElementsDirty(Element element) { void markElementsDirty(Element element) {
if (element == null) { if (element == null) {
return; return;
......
...@@ -48,7 +48,7 @@ typedef DragEndCallback = void Function(DraggableDetails details); ...@@ -48,7 +48,7 @@ typedef DragEndCallback = void Function(DraggableDetails details);
/// Signature for when a [Draggable] leaves a [DragTarget]. /// Signature for when a [Draggable] leaves a [DragTarget].
/// ///
/// Used by [DragTarget.onLeave]. /// Used by [DragTarget.onLeave].
typedef DragTargetLeave<T> = void Function(T data); typedef DragTargetLeave = void Function(Object data);
/// Where the [Draggable] should be anchored during a drag. /// Where the [Draggable] should be anchored during a drag.
enum DragAnchor { enum DragAnchor {
...@@ -502,7 +502,7 @@ class DragTarget<T> extends StatefulWidget { ...@@ -502,7 +502,7 @@ class DragTarget<T> extends StatefulWidget {
/// Called when a given piece of data being dragged over this target leaves /// Called when a given piece of data being dragged over this target leaves
/// the target. /// the target.
final DragTargetLeave<T> onLeave; final DragTargetLeave onLeave;
@override @override
_DragTargetState<T> createState() => _DragTargetState<T>(); _DragTargetState<T> createState() => _DragTargetState<T>();
...@@ -514,13 +514,12 @@ List<T> _mapAvatarsToData<T>(List<_DragAvatar<T>> avatars) { ...@@ -514,13 +514,12 @@ List<T> _mapAvatarsToData<T>(List<_DragAvatar<T>> avatars) {
class _DragTargetState<T> extends State<DragTarget<T>> { class _DragTargetState<T> extends State<DragTarget<T>> {
final List<_DragAvatar<T>> _candidateAvatars = <_DragAvatar<T>>[]; final List<_DragAvatar<T>> _candidateAvatars = <_DragAvatar<T>>[];
final List<_DragAvatar<dynamic>> _rejectedAvatars = <_DragAvatar<dynamic>>[]; final List<_DragAvatar<Object>> _rejectedAvatars = <_DragAvatar<Object>>[];
bool didEnter(_DragAvatar<dynamic> avatar) { bool didEnter(_DragAvatar<Object> avatar) {
assert(!_candidateAvatars.contains(avatar)); assert(!_candidateAvatars.contains(avatar));
assert(!_rejectedAvatars.contains(avatar)); assert(!_rejectedAvatars.contains(avatar));
final dynamic data = avatar.data; if (avatar is _DragAvatar<T> && (widget.onWillAccept == null || widget.onWillAccept(avatar.data))) {
if (data is T && (widget.onWillAccept == null || widget.onWillAccept(data))) {
setState(() { setState(() {
_candidateAvatars.add(avatar); _candidateAvatars.add(avatar);
}); });
...@@ -533,7 +532,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> { ...@@ -533,7 +532,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
} }
} }
void didLeave(_DragAvatar<dynamic> avatar) { void didLeave(_DragAvatar<Object> avatar) {
assert(_candidateAvatars.contains(avatar) || _rejectedAvatars.contains(avatar)); assert(_candidateAvatars.contains(avatar) || _rejectedAvatars.contains(avatar));
if (!mounted) if (!mounted)
return; return;
...@@ -545,7 +544,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> { ...@@ -545,7 +544,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
widget.onLeave(avatar.data); widget.onLeave(avatar.data);
} }
void didDrop(_DragAvatar<dynamic> avatar) { void didDrop(_DragAvatar<Object> avatar) {
assert(_candidateAvatars.contains(avatar)); assert(_candidateAvatars.contains(avatar));
if (!mounted) if (!mounted)
return; return;
...@@ -553,7 +552,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> { ...@@ -553,7 +552,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
_candidateAvatars.remove(avatar); _candidateAvatars.remove(avatar);
}); });
if (widget.onAccept != null) if (widget.onAccept != null)
widget.onAccept(avatar.data); widget.onAccept(avatar.data as T);
} }
@override @override
...@@ -562,7 +561,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> { ...@@ -562,7 +561,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
return MetaData( return MetaData(
metaData: this, metaData: this,
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
child: widget.builder(context, _mapAvatarsToData<T>(_candidateAvatars), _mapAvatarsToData<dynamic>(_rejectedAvatars)), child: widget.builder(context, _mapAvatarsToData<T>(_candidateAvatars), _mapAvatarsToData<Object>(_rejectedAvatars)),
); );
} }
} }
......
...@@ -90,13 +90,21 @@ void main() { ...@@ -90,13 +90,21 @@ void main() {
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return Container(height: 100.0, child: const Text('Target 1')); return Container(height: 100.0, child: const Text('Target 1'));
}, },
onLeave: (int data) => leftBehind['Target 1'] = leftBehind['Target 1'] + data, onLeave: (Object data) {
if (data is int) {
leftBehind['Target 1'] = leftBehind['Target 1'] + data;
}
},
), ),
DragTarget<int>( DragTarget<int>(
builder: (BuildContext context, List<int> data, List<dynamic> rejects) { builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
return Container(height: 100.0, child: const Text('Target 2')); return Container(height: 100.0, child: const Text('Target 2'));
}, },
onLeave: (int data) => leftBehind['Target 2'] = leftBehind['Target 2'] + data, onLeave: (Object data) {
if (data is int) {
leftBehind['Target 2'] = leftBehind['Target 2'] + data;
}
},
), ),
], ],
), ),
......
# Override the parent analysis_options until all the repo has implicit-casts: false
include: ../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
...@@ -2,8 +2,3 @@ ...@@ -2,8 +2,3 @@
# the ones from above, which include the `public_member_api_docs` rule). # the ones from above, which include the `public_member_api_docs` rule).
include: ../../analysis_options.yaml include: ../../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
...@@ -2,8 +2,3 @@ ...@@ -2,8 +2,3 @@
# the ones from above, which include the `public_member_api_docs` rule). # the ones from above, which include the `public_member_api_docs` rule).
include: ../../analysis_options.yaml include: ../../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
# Override the parent analysis_options until all the repo has implicit-casts: false
include: ../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter:
rules:
avoid_as: false
include: ../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
include: ../../analysis_options.yaml include: ../../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
linter: linter:
rules: rules:
unawaited_futures: true unawaited_futures: true
......
# Override the parent analysis_options until all the repo has implicit-casts: false
include: ../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
# Override the parent analysis_options until all the repo has implicit-casts: false
include: ../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment