Unverified Commit 340d9e00 authored by Vyacheslav Egorov's avatar Vyacheslav Egorov Committed by GitHub

Fix various strong mode issues. (#14284)

parent 12279613
...@@ -15,9 +15,11 @@ const double todoCost = 1009.0; // about two average SWE days, in dollars ...@@ -15,9 +15,11 @@ const double todoCost = 1009.0; // about two average SWE days, in dollars
const double ignoreCost = 2003.0; // four average SWE days, in dollars const double ignoreCost = 2003.0; // four average SWE days, in dollars
const double pythonCost = 3001.0; // six average SWE days, in dollars const double pythonCost = 3001.0; // six average SWE days, in dollars
const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring, 15 to fix the bugs we missed because the test was off const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring, 15 to fix the bugs we missed because the test was off
const double asDynamicCost = 2003.0; // same as ignoring analyzer warning
final RegExp todoPattern = new RegExp(r'(?://|#) *TODO'); final RegExp todoPattern = new RegExp(r'(?://|#) *TODO');
final RegExp ignorePattern = new RegExp(r'// *ignore:'); final RegExp ignorePattern = new RegExp(r'// *ignore:');
final RegExp asDynamicPattern = new RegExp(r'as dynamic');
Future<double> findCostsForFile(File file) async { Future<double> findCostsForFile(File file) async {
if (path.extension(file.path) == '.py') if (path.extension(file.path) == '.py')
...@@ -33,6 +35,8 @@ Future<double> findCostsForFile(File file) async { ...@@ -33,6 +35,8 @@ Future<double> findCostsForFile(File file) async {
total += todoCost; total += todoCost;
if (line.contains(ignorePattern)) if (line.contains(ignorePattern))
total += ignoreCost; total += ignoreCost;
if (line.contains(asDynamicPattern))
total += asDynamicCost;
if (isTest && line.contains('skip:')) if (isTest && line.contains('skip:'))
total += skipCost; total += skipCost;
} }
......
...@@ -168,6 +168,8 @@ class DemoItem<T> { ...@@ -168,6 +168,8 @@ class DemoItem<T> {
); );
}; };
} }
Widget build() => builder(this);
} }
class ExpasionPanelsDemo extends StatefulWidget { class ExpasionPanelsDemo extends StatefulWidget {
...@@ -351,7 +353,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> { ...@@ -351,7 +353,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
return new ExpansionPanel( return new ExpansionPanel(
isExpanded: item.isExpanded, isExpanded: item.isExpanded,
headerBuilder: item.headerBuilder, headerBuilder: item.headerBuilder,
body: item.builder(item) body: item.build()
); );
}).toList() }).toList()
), ),
......
...@@ -867,7 +867,8 @@ class _NestedScrollController extends ScrollController { ...@@ -867,7 +867,8 @@ class _NestedScrollController extends ScrollController {
} }
Iterable<_NestedScrollPosition> get nestedPositions sync* { Iterable<_NestedScrollPosition> get nestedPositions sync* {
yield* positions; // TODO(vegorov) use instance method version of castFrom when it is available.
yield* Iterable.castFrom<ScrollPosition, _NestedScrollPosition>(positions);
} }
} }
......
...@@ -198,7 +198,7 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator> ...@@ -198,7 +198,7 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
} }
} }
} else if (notification is ScrollEndNotification || notification is ScrollUpdateNotification) { } else if (notification is ScrollEndNotification || notification is ScrollUpdateNotification) {
if (notification.dragDetails != null) { // ignore: undefined_getter if ((notification as dynamic).dragDetails != null) {
_leadingController.scrollEnd(); _leadingController.scrollEnd();
_trailingController.scrollEnd(); _trailingController.scrollEnd();
} }
......
...@@ -463,7 +463,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -463,7 +463,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
)); ));
assert(_parentZone != null); assert(_parentZone != null);
assert(_pendingExceptionDetails != null, 'A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.'); assert(_pendingExceptionDetails != null, 'A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.');
_parentZone.run<Null>(_testCompletionHandler); _parentZone.run<void>(_testCompletionHandler);
} }
); );
_parentZone = Zone.current; _parentZone = Zone.current;
......
...@@ -132,8 +132,12 @@ class WidgetController { ...@@ -132,8 +132,12 @@ class WidgetController {
Iterable<State> get allStates { Iterable<State> get allStates {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return allElements return allElements
// TODO(vegorov) replace with Iterable.whereType, when it is available. https://github.com/dart-lang/sdk/issues/27827
.where((Element element) => element is StatefulElement) .where((Element element) => element is StatefulElement)
.map((StatefulElement element) => element.state); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27827 .map((Element element) {
final StatefulElement statefulElement = element;
return statefulElement.state;
});
} }
/// The matching state in the widget tree. /// The matching state in the widget tree.
......
...@@ -479,7 +479,10 @@ void main() { ...@@ -479,7 +479,10 @@ void main() {
return test.main; return test.main;
}); });
WebSocket.connect(server).then((WebSocket socket) { WebSocket.connect(server).then((WebSocket socket) {
socket.map(JSON.decode).pipe(channel.sink); socket.map((dynamic x) {
assert(x is String);
return JSON.decode(x);
}).pipe(channel.sink);
socket.addStream(channel.stream.map(JSON.encode)); socket.addStream(channel.stream.map(JSON.encode));
}); });
} }
......
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