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