Replace @checked with covariant (#8300)

Fixes #7734
This commit is contained in:
Alexandre Ardhuin 2017-02-21 18:30:22 +01:00 committed by Adam Barth
parent 1e1f7703cc
commit da925c7d71
24 changed files with 56 additions and 63 deletions

View file

@ -111,7 +111,7 @@ class ShrineGridDelegate extends SliverGridDelegate {
}
@override
bool shouldRelayout(@checked SliverGridDelegate oldDelegate) => false;
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) => false;
}
/// Displays the Vendor's name and avatar.

View file

@ -21,7 +21,6 @@ export 'src/foundation/print.dart';
export 'src/foundation/synchronous_future.dart';
export 'package:meta/meta.dart' show
checked,
mustCallSuper,
optionalTypeArgs,
protected,

View file

@ -552,7 +552,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
}
@override
bool shouldRebuild(@checked _SliverAppBarDelegate oldDelegate) {
bool shouldRebuild(covariant _SliverAppBarDelegate oldDelegate) {
return leading != oldDelegate.leading
|| title != oldDelegate.title
|| actions != oldDelegate.actions

View file

@ -958,7 +958,7 @@ class _IntrinsicDimensionsCacheEntry {
/// these classes, however, you must implement the algorithm yourself.
abstract class RenderBox extends RenderObject {
@override
void setupParentData(@checked RenderObject child) {
void setupParentData(covariant RenderObject child) {
if (child.parentData is! BoxParentData)
child.parentData = new BoxParentData();
}
@ -1863,7 +1863,7 @@ abstract class RenderBox extends RenderObject {
/// ```
// TODO(ianh): Fix the type of the argument here once https://github.com/dart-lang/sdk/issues/25232 is fixed
@override
void handleEvent(PointerEvent event, @checked HitTestEntry entry) {
void handleEvent(PointerEvent event, covariant HitTestEntry entry) {
super.handleEvent(event, entry);
}

View file

@ -243,7 +243,7 @@ abstract class MultiChildLayoutDelegate {
/// This should compare the fields of the current delegate and the given
/// `oldDelegate` and return true if the fields are such that the layout would
/// be different.
bool shouldRelayout(@checked MultiChildLayoutDelegate oldDelegate);
bool shouldRelayout(covariant MultiChildLayoutDelegate oldDelegate);
/// Override this method to include additional information in the
/// debugging data printed by [debugDumpRenderTree] and friends.

View file

@ -108,7 +108,7 @@ abstract class FlowDelegate {
/// This should compare the fields of the current delegate and the given
/// oldDelegate and return true if the fields are such that the layout would
/// be different.
bool shouldRelayout(@checked FlowDelegate oldDelegate) => false;
bool shouldRelayout(covariant FlowDelegate oldDelegate) => false;
/// Override this method to return true when the children need to be
/// repainted. This should compare the fields of the current delegate and the
@ -123,7 +123,7 @@ abstract class FlowDelegate {
/// The flow container might repaint even if this function returns false, for
/// example if layout triggers painting (e.g., if [shouldRelayout] returns
/// true).
bool shouldRepaint(@checked FlowDelegate oldDelegate);
bool shouldRepaint(covariant FlowDelegate oldDelegate);
/// Override this method to include additional information in the
/// debugging data printed by [debugDumpRenderTree] and friends.

View file

@ -83,7 +83,7 @@ class AbstractNode {
/// Subclasses with children should [attach] all their children to the same
/// [owner] whenever this method is called.
@mustCallSuper
void attach(@checked Object owner) {
void attach(covariant Object owner) {
assert(owner != null);
assert(_owner == null);
_owner = owner;
@ -111,7 +111,7 @@ class AbstractNode {
/// Subclasses should call this function when they acquire a new child.
@protected
@mustCallSuper
void adoptChild(@checked AbstractNode child) {
void adoptChild(covariant AbstractNode child) {
assert(child != null);
assert(child._parent == null);
assert(() {
@ -132,7 +132,7 @@ class AbstractNode {
/// Subclasses should call this function when they lose a child.
@protected
@mustCallSuper
void dropChild(@checked AbstractNode child) {
void dropChild(covariant AbstractNode child) {
assert(child != null);
assert(child._parent == this);
assert(child.attached == attached);

View file

@ -1255,7 +1255,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
///
/// You can call this function to set up the parent data for child before the
/// child is added to the parent's child list.
void setupParentData(@checked RenderObject child) {
void setupParentData(covariant RenderObject child) {
assert(_debugCanPerformMutations);
if (child.parentData is! ParentData)
child.parentData = new ParentData();
@ -2143,7 +2143,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
///
/// Used by coordinate conversion functions to translate coordinates local to
/// one render object into coordinates local to another render object.
void applyPaintTransform(@checked RenderObject child, Matrix4 transform) {
void applyPaintTransform(covariant RenderObject child, Matrix4 transform) {
assert(child.parent == this);
}
@ -2155,7 +2155,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
///
/// This is used in the semantics phase to avoid including children
/// that are not physically visible.
Rect describeApproximatePaintClip(@checked RenderObject child) => null;
Rect describeApproximatePaintClip(covariant RenderObject child) => null;
// SEMANTICS
@ -2383,7 +2383,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// Override this method to handle pointer events that hit this render object.
@override
void handleEvent(PointerEvent event, @checked HitTestEntry entry) { }
void handleEvent(PointerEvent event, covariant HitTestEntry entry) { }
// HIT TESTING

View file

@ -918,7 +918,7 @@ abstract class CustomClipper<T> {
/// It's possible that the [getClip] method will get called even if
/// [shouldReclip] returns false or if the [shouldReclip] method is never
/// called at all (e.g. if the box changes size).
bool shouldReclip(@checked CustomClipper<T> oldClipper);
bool shouldReclip(covariant CustomClipper<T> oldClipper);
}
abstract class _RenderCustomClip<T> extends RenderProxyBox {
@ -1761,7 +1761,7 @@ abstract class CustomPainter {
/// repaints should be avoided as much as possible, a [RepaintBoundary] or
/// [RenderRepaintBoundary] (or other render object with [isRepaintBoundary]
/// set to true) might be helpful.
bool shouldRepaint(@checked CustomPainter oldDelegate);
bool shouldRepaint(covariant CustomPainter oldDelegate);
/// Called whenever a hit test is being performed on an object that is using
/// this custom paint delegate.

View file

@ -4,8 +4,6 @@
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'box.dart';
import 'debug.dart';
import 'object.dart';
@ -748,7 +746,7 @@ abstract class SingleChildLayoutDelegate {
/// It's also possible that the layout method will get called
/// without [shouldRelayout] being called at all (e.g. if the parent changes
/// size).
bool shouldRelayout(@checked SingleChildLayoutDelegate oldDelegate);
bool shouldRelayout(covariant SingleChildLayoutDelegate oldDelegate);
}
/// Defers the layout of its single child to a delegate.

View file

@ -913,7 +913,7 @@ abstract class RenderSliver extends RenderObject {
/// of the sliver whereas [childScrollOffset] gives the distance from sliver's
/// zero scroll offset.
@protected
double childMainAxisPosition(@checked RenderObject child) {
double childMainAxisPosition(covariant RenderObject child) {
assert(() {
throw new FlutterError('$runtimeType does not implement childPosition.');
});
@ -931,7 +931,7 @@ abstract class RenderSliver extends RenderObject {
///
/// Calling this for a child that is not visible is not valid.
@protected
double childCrossAxisPosition(@checked RenderObject child) => 0.0;
double childCrossAxisPosition(covariant RenderObject child) => 0.0;
/// Returns the scroll offset for the leading edge of the given child.
///
@ -941,7 +941,7 @@ abstract class RenderSliver extends RenderObject {
/// [childMainAxisPosition] gives the distance from the leading _visible_ edge
/// of the sliver whereas [childScrollOffset] gives the distance from sliver's
/// zero scroll offset.
double childScrollOffset(@checked RenderObject child) {
double childScrollOffset(covariant RenderObject child) {
assert(child.parent == this);
return 0.0;
}

View file

@ -227,7 +227,7 @@ abstract class SliverGridDelegate {
/// Returns information about the size and position of the tiles in the grid.
SliverGridLayout getLayout(SliverConstraints constraints);
bool shouldRelayout(@checked SliverGridDelegate oldDelegate);
bool shouldRelayout(covariant SliverGridDelegate oldDelegate);
}
/// Creates grid layouts with a fixed number of tiles in the cross axis.

View file

@ -133,7 +133,7 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje
///
/// If there is no child, this should return 0.0.
@override
double childMainAxisPosition(@checked RenderObject child) => super.childMainAxisPosition(child);
double childMainAxisPosition(covariant RenderObject child) => super.childMainAxisPosition(child);
@override
bool hitTestChildren(HitTestResult result, { @required double mainAxisPosition, @required double crossAxisPosition }) {

View file

@ -1860,7 +1860,7 @@ class Flex extends MultiChildRenderObjectWidget {
}
@override
void updateRenderObject(BuildContext context, @checked RenderFlex renderObject) {
void updateRenderObject(BuildContext context, covariant RenderFlex renderObject) {
renderObject
..direction = direction
..mainAxisAlignment = mainAxisAlignment

View file

@ -824,7 +824,7 @@ abstract class State<T extends StatefulWidget> {
/// super.didUpdateConfig(oldConfig).
// TODO(abarth): Add @mustCallSuper.
@protected
void didUpdateConfig(@checked T oldConfig) { }
void didUpdateConfig(covariant T oldConfig) { }
/// Called whenever the application is reassembled during debugging.
///
@ -1189,7 +1189,7 @@ abstract class InheritedWidget extends ProxyWidget {
/// The given widget is guaranteed to have the same [runtimeType] as this
/// object.
@protected
bool updateShouldNotify(@checked InheritedWidget oldWidget);
bool updateShouldNotify(covariant InheritedWidget oldWidget);
}
/// RenderObjectWidgets provide the configuration for [RenderObjectElement]s,
@ -1226,13 +1226,13 @@ abstract class RenderObjectWidget extends Widget {
/// [createElement] method. See, for example,
/// [SingleChildRenderObjectElement.update].
@protected
void updateRenderObject(BuildContext context, @checked RenderObject renderObject) { }
void updateRenderObject(BuildContext context, covariant RenderObject renderObject) { }
/// A render object previously associated with this widget has been removed
/// from the tree. The given [RenderObject] will be of the same type as
/// returned by this object's [createRenderObject].
@protected
void didUnmountRenderObject(@checked RenderObject renderObject) { }
void didUnmountRenderObject(covariant RenderObject renderObject) { }
}
/// A superclass for RenderObjectWidgets that configure RenderObject subclasses
@ -2141,7 +2141,7 @@ abstract class Element implements BuildContext {
///
/// This function is called only during the "active" lifecycle state.
@mustCallSuper
void update(@checked Widget newWidget) {
void update(covariant Widget newWidget) {
// This code is hot when hot reloading, so we try to
// only call _AssertionError._evaluateAssertion once.
assert(_debugLifecycleState == _ElementLifecycle.active
@ -3159,7 +3159,7 @@ abstract class ProxyElement extends ComponentElement {
/// Called during [update] after changing the widget associated with this
/// element but before rebuilding this element.
@protected
void notifyClients(@checked ProxyWidget oldWidget);
void notifyClients(covariant ProxyWidget oldWidget);
}
/// An [Element] that uses a [ParentDataWidget] as its configuration.
@ -3483,7 +3483,7 @@ abstract class RenderObjectElement extends BuildableElement {
}
@override
void update(@checked RenderObjectWidget newWidget) {
void update(covariant RenderObjectWidget newWidget) {
super.update(newWidget);
assert(widget == newWidget);
assert(() { _debugUpdateRenderObjectOwner(); return true; });
@ -3729,7 +3729,7 @@ abstract class RenderObjectElement extends BuildableElement {
/// element has a list of children, the previous sibling is a convenient value
/// for the slot.
@protected
void insertChildRenderObject(@checked RenderObject child, @checked dynamic slot);
void insertChildRenderObject(covariant RenderObject child, covariant dynamic slot);
/// Move the given child to the given slot.
///
@ -3740,13 +3740,13 @@ abstract class RenderObjectElement extends BuildableElement {
/// element has a list of children, the previous sibling is a convenient value
/// for the slot.
@protected
void moveChildRenderObject(@checked RenderObject child, @checked dynamic slot);
void moveChildRenderObject(covariant RenderObject child, covariant dynamic slot);
/// Remove the given child from [renderObject].
///
/// The given child is guaranteed to have [renderObject] as its parent.
@protected
void removeChildRenderObject(@checked RenderObject child);
void removeChildRenderObject(covariant RenderObject child);
@override
void debugFillDescription(List<String> description) {

View file

@ -53,7 +53,7 @@ class ScrollBehavior {
return null;
}
bool shouldNotify(@checked ScrollBehavior oldDelegate) => false;
bool shouldNotify(covariant ScrollBehavior oldDelegate) => false;
}
class ScrollConfiguration extends InheritedWidget {

View file

@ -38,7 +38,7 @@ abstract class SliverChildDelegate {
double trailingScrollOffset,
) => null;
bool shouldRebuild(@checked SliverChildDelegate oldDelegate);
bool shouldRebuild(covariant SliverChildDelegate oldDelegate);
@override
String toString() {
@ -81,7 +81,7 @@ class SliverChildBuilderDelegate extends SliverChildDelegate {
int get estimatedChildCount => childCount;
@override
bool shouldRebuild(@checked SliverChildBuilderDelegate oldDelegate) => true;
bool shouldRebuild(covariant SliverChildBuilderDelegate oldDelegate) => true;
}
// ///
@ -127,7 +127,7 @@ class SliverChildListDelegate extends SliverChildDelegate {
int get estimatedChildCount => children.length;
@override
bool shouldRebuild(@checked SliverChildListDelegate oldDelegate) {
bool shouldRebuild(covariant SliverChildListDelegate oldDelegate) {
return children != oldDelegate.children;
}
}
@ -427,7 +427,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
}
@override
void insertChildRenderObject(@checked RenderObject child, int slot) {
void insertChildRenderObject(covariant RenderObject child, int slot) {
assert(slot != null);
assert(_currentlyUpdatingChildIndex == slot);
renderObject.insert(child, after: _currentBeforeChild);
@ -439,14 +439,14 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
}
@override
void moveChildRenderObject(@checked RenderObject child, int slot) {
void moveChildRenderObject(covariant RenderObject child, int slot) {
// TODO(ianh): At some point we should be better about noticing when a
// particular LocalKey changes slot, and handle moving the nodes around.
assert(false);
}
@override
void removeChildRenderObject(@checked RenderObject child) {
void removeChildRenderObject(covariant RenderObject child) {
assert(_currentlyUpdatingChildIndex != null);
renderObject.remove(child);
}

View file

@ -18,7 +18,7 @@ abstract class SliverPersistentHeaderDelegate {
double get maxExtent;
bool shouldRebuild(@checked SliverPersistentHeaderDelegate oldDelegate);
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate);
}
class SliverPersistentHeader extends StatelessWidget {
@ -116,17 +116,17 @@ class _SliverPersistentHeaderElement extends RenderObjectElement {
}
@override
void insertChildRenderObject(@checked RenderObject child, Null slot) {
void insertChildRenderObject(covariant RenderObject child, Null slot) {
renderObject.child = child;
}
@override
void moveChildRenderObject(@checked RenderObject child, Null slot) {
void moveChildRenderObject(covariant RenderObject child, Null slot) {
assert(false);
}
@override
void removeChildRenderObject(@checked RenderObject child) {
void removeChildRenderObject(covariant RenderObject child) {
renderObject.child = null;
}

View file

@ -11,7 +11,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meta/meta.dart';
class TestImage extends ui.Image {
TestImage(this.scale);
@ -97,7 +96,7 @@ class TestAssetImage extends AssetImage {
}
@override
Future<ui.Image> decodeImage(@checked TestByteData data) {
Future<ui.Image> decodeImage(covariant TestByteData data) {
return new SynchronousFuture<ui.Image>(new TestImage(data.scale));
}
}

View file

@ -6,7 +6,6 @@ import 'dart:collection';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';
final List<String> results = <String>[];
@ -45,7 +44,7 @@ class TestRoute extends LocalHistoryRoute<String> {
}
@override
void didReplace(@checked TestRoute oldRoute) {
void didReplace(covariant TestRoute oldRoute) {
log('didReplace ${oldRoute.name}');
super.didReplace(oldRoute);
}
@ -60,13 +59,13 @@ class TestRoute extends LocalHistoryRoute<String> {
}
@override
void didPopNext(@checked TestRoute nextRoute) {
void didPopNext(covariant TestRoute nextRoute) {
log('didPopNext ${nextRoute.name}');
super.didPopNext(nextRoute);
}
@override
void didChangeNext(@checked TestRoute nextRoute) {
void didChangeNext(covariant TestRoute nextRoute) {
log('didChangeNext ${nextRoute?.name}');
super.didChangeNext(nextRoute);
}

View file

@ -125,7 +125,7 @@ class _HasSemantics extends Matcher {
final TestSemantics _semantics;
@override
bool matches(@checked SemanticsTester item, Map<dynamic, dynamic> matchState) {
bool matches(covariant SemanticsTester item, Map<dynamic, dynamic> matchState) {
return _semantics._matches(item.tester.binding.pipelineOwner.semanticsOwner.rootSemanticsNode, matchState);
}

View file

@ -3,7 +3,6 @@
// found in the LICENSE file.
import 'package:markdown/markdown.dart' as md;
import 'package:meta/meta.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart';
@ -67,7 +66,7 @@ class MarkdownRaw extends StatelessWidget {
MarkdownBodyRaw createMarkdownBody({
String data,
@checked MarkdownStyleRaw markdownStyle,
covariant MarkdownStyleRaw markdownStyle,
SyntaxHighlighter syntaxHighlighter,
MarkdownLinkCallback onTapLink
}) {

View file

@ -847,7 +847,7 @@ class _LiveTestRenderView extends RenderView {
@override
TestViewConfiguration get configuration => super.configuration;
@override
set configuration(@checked TestViewConfiguration value) { super.configuration = value; }
set configuration(covariant TestViewConfiguration value) { super.configuration = value; }
final Map<int, _LiveTestPointerRecord> _pointers = <int, _LiveTestPointerRecord>{};

View file

@ -4,7 +4,6 @@
import 'package:flutter/material.dart';
import 'package:test/test.dart';
import 'package:meta/meta.dart';
import 'finders.dart';
@ -96,7 +95,7 @@ class _FindsWidgetMatcher extends Matcher {
final int max;
@override
bool matches(@checked Finder finder, Map<dynamic, dynamic> matchState) {
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) {
assert(min != null || max != null);
assert(min == null || max == null || min <= max);
matchState[Finder] = finder;
@ -190,7 +189,7 @@ class _IsOffstage extends Matcher {
const _IsOffstage();
@override
bool matches(@checked Finder finder, Map<dynamic, dynamic> matchState) {
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) {
return _hasAncestorMatching(finder, (Widget widget) {
if (widget is Offstage)
return widget.offstage;
@ -206,7 +205,7 @@ class _IsOnstage extends Matcher {
const _IsOnstage();
@override
bool matches(@checked Finder finder, Map<dynamic, dynamic> matchState) {
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) {
Iterable<Element> nodes = finder.evaluate();
if (nodes.length != 1)
return false;
@ -230,7 +229,7 @@ class _IsInCard extends Matcher {
const _IsInCard();
@override
bool matches(@checked Finder finder, Map<dynamic, dynamic> matchState) => _hasAncestorOfType(finder, Card);
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) => _hasAncestorOfType(finder, Card);
@override
Description describe(Description description) => description.add('in card');
@ -240,7 +239,7 @@ class _IsNotInCard extends Matcher {
const _IsNotInCard();
@override
bool matches(@checked Finder finder, Map<dynamic, dynamic> matchState) => !_hasAncestorOfType(finder, Card);
bool matches(covariant Finder finder, Map<dynamic, dynamic> matchState) => !_hasAncestorOfType(finder, Card);
@override
Description describe(Description description) => description.add('not in card');