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
const double ignoreCost = 2003.0; // four 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 asDynamicCost = 2003.0; // same as ignoring analyzer warning
final RegExp todoPattern = new RegExp(r'(?://|#) *TODO');
final RegExp ignorePattern = new RegExp(r'// *ignore:');
final RegExp asDynamicPattern = new RegExp(r'as dynamic');
Future<double> findCostsForFile(File file) async {
if (path.extension(file.path) == '.py')
......@@ -33,6 +35,8 @@ Future<double> findCostsForFile(File file) async {
total += todoCost;
if (line.contains(ignorePattern))
total += ignoreCost;
if (line.contains(asDynamicPattern))
total += asDynamicCost;
if (isTest && line.contains('skip:'))
total += skipCost;
}
......
......@@ -168,6 +168,8 @@ class DemoItem<T> {
);
};
}
Widget build() => builder(this);
}
class ExpasionPanelsDemo extends StatefulWidget {
......@@ -351,7 +353,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
return new ExpansionPanel(
isExpanded: item.isExpanded,
headerBuilder: item.headerBuilder,
body: item.builder(item)
body: item.build()
);
}).toList()
),
......
......@@ -867,7 +867,8 @@ class _NestedScrollController extends ScrollController {
}
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>
}
}
} else if (notification is ScrollEndNotification || notification is ScrollUpdateNotification) {
if (notification.dragDetails != null) { // ignore: undefined_getter
if ((notification as dynamic).dragDetails != null) {
_leadingController.scrollEnd();
_trailingController.scrollEnd();
}
......
......@@ -463,7 +463,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
));
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.');
_parentZone.run<Null>(_testCompletionHandler);
_parentZone.run<void>(_testCompletionHandler);
}
);
_parentZone = Zone.current;
......
......@@ -132,8 +132,12 @@ class WidgetController {
Iterable<State> get allStates {
TestAsyncUtils.guardSync();
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)
.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.
......
......@@ -479,7 +479,10 @@ void main() {
return test.main;
});
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));
});
}
......
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