Unverified Commit 4055e196 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

implicit-casts:false in flutter/lib/src/foundation (#45503)

parent 9e72a80a
......@@ -28,17 +28,19 @@ class BitField<T extends dynamic> implements bitfield.BitField<T> {
@override
bool operator [](T index) {
assert(index.index < _length);
return (_bits & 1 << index.index) > 0;
final int _index = index.index as int;
assert(_index < _length);
return (_bits & 1 << _index) > 0;
}
@override
void operator []=(T index, bool value) {
assert(index.index < _length);
final int _index = index.index as int;
assert(_index < _length);
if (value)
_bits = _bits | (1 << index.index);
_bits = _bits | (1 << _index);
else
_bits = _bits & ~(1 << index.index);
_bits = _bits & ~(1 << _index);
}
@override
......
......@@ -38,7 +38,7 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St
assert(errorData is List<dynamic>);
assert(errorData.length == 2);
final Exception exception = Exception(errorData[0]);
final StackTrace stack = StackTrace.fromString(errorData[1]);
final StackTrace stack = StackTrace.fromString(errorData[1] as String);
if (result.isCompleted) {
Zone.current.handleUncaughtError(exception, stack);
} else {
......@@ -48,7 +48,7 @@ Future<R> compute<Q, R>(isolates.ComputeCallback<Q, R> callback, Q message, { St
resultPort.listen((dynamic resultData) {
assert(resultData == null || resultData is R);
if (!result.isCompleted)
result.complete(resultData);
result.complete(resultData as R);
});
await result.future;
Timeline.startSync('$debugLabel: end', flow: Flow.end(flow.id));
......@@ -74,7 +74,7 @@ class _IsolateConfiguration<Q, R> {
final String debugLabel;
final int flowId;
R apply() => callback(message);
FutureOr<R> apply() => callback(message);
}
Future<void> _spawn<Q, R>(_IsolateConfiguration<Q, FutureOr<R>> configuration) async {
......
......@@ -335,7 +335,7 @@ class FlutterErrorDetails extends Diagnosticable {
}
longMessage ??= fullMessage;
} else if (exception is String) {
longMessage = exception;
longMessage = exception as String;
} else if (exception is Error || exception is Exception) {
longMessage = exception.toString();
} else {
......@@ -349,10 +349,10 @@ class FlutterErrorDetails extends Diagnosticable {
Diagnosticable _exceptionToDiagnosticable() {
if (exception is FlutterError) {
return exception;
return exception as FlutterError;
}
if (exception is AssertionError && exception.message is FlutterError) {
return exception.message;
return exception.message as FlutterError;
}
return null;
}
......
......@@ -3110,7 +3110,7 @@ mixin DiagnosticableMixin {
DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) {
return DiagnosticableNode<Diagnosticable>(
name: name,
value: this,
value: this as Diagnosticable,
style: style,
);
}
......
......@@ -67,8 +67,8 @@ class ValueKey<T> extends LocalKey {
bool operator ==(dynamic other) {
if (other.runtimeType != runtimeType)
return false;
final ValueKey<T> typedOther = other;
return value == typedOther.value;
return other is ValueKey<T>
&& other.value == value;
}
@override
......
......@@ -31,25 +31,25 @@ class SynchronousFuture<T> implements Future<T> {
}
@override
Future<T> catchError(Function onError, { bool test(dynamic error) }) => Completer<T>().future;
Future<T> catchError(Function onError, { bool test(Object error) }) => Completer<T>().future;
@override
Future<E> then<E>(dynamic f(T value), { Function onError }) {
Future<E> then<E>(FutureOr<E> f(T value), { Function onError }) {
final dynamic result = f(_value);
if (result is Future<E>)
return result;
return SynchronousFuture<E>(result);
return SynchronousFuture<E>(result as E);
}
@override
Future<T> timeout(Duration timeLimit, { dynamic onTimeout() }) {
Future<T> timeout(Duration timeLimit, { FutureOr<T> onTimeout() }) {
return Future<T>.value(_value).timeout(timeLimit, onTimeout: onTimeout);
}
@override
Future<T> whenComplete(dynamic action()) {
Future<T> whenComplete(FutureOr<dynamic> action()) {
try {
final dynamic result = action();
final FutureOr<dynamic> result = action();
if (result is Future)
return result.then<T>((dynamic value) => _value);
return this;
......
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