anchor.diff:    Future cancel() => _completer._cancel();
   
     /// Whether this operation has been canceled before it completed.
  -  bool get isCanceled => _completer.isCanceled;
  +  bool get isCanceled => _completer._isCanceled;
   
     /// Whether the result of this operation is ready.
     ///
     /// When ready, the [value] future is completed with the result value
     /// or error, and this operation can no longer be cancelled.
     /// An operation may be complete before the listeners on [value] are invoked.
  -  bool get isCompleted => _completer._inner.isCompleted;
  +  bool get isCompleted => _completer._isCompleted;
   }
   
   /// A completer for a [CancelableOperation].
   class CancelableCompleter<T> {
  +  // The cancelable completer is in one of the following states:
  +  // * Initial:
  +  //      _inner != null
  +  //      _cancelCompleter != null
  +  //      _mayComplete: true
  +  //
  +  // * Async-completed: `complete` called with a future while Initial.
  +  //      _inner != null
  +  //      _cancelCompleter != null
  +  //      _mayComplete: false
  +  //
  +  // * Completed: `complete` called with a value or `completeError` called
  +  //     while Initial, or the future passed in Async-completed completes
  +  //     while AsyncCompleted.
  +  //      _inner != null
  +  //      _cancelCompleter == null
  +  //      _mayComplete: false
  +  //
  +  // * Cancelled may-complete: `_cancel` called while Initial.
  +  //      Allows calling `complete`/`completeError` even if it does nothing.
  +  //      _inner == null
  +  //      _cancelCompleter != null
  +  //      _mayComplete: true
  +  //
  +  // * Cancelled can't-complete: `_cancel` called while Async-completed.
  +  //      _inner == null
  +  //      _cancelCompleter != null
  +  //      _mayComplete: false
  +
     /// The completer for the wrapped future.
     ///
     /// At most one of `_inner.future` and `_cancelCompleter.future` will
     /// ever complete.
  -  final _inner = Completer<T>();
  +  /// Set to `null` when when the operation is canceled, because then
  +  /// it's guaranteed that this completer will never complete.
  +  Completer<T>? _inner = Completer<T>();
   
     /// Completed when `cancel` is called.
     ///
     /// At most one of `_inner.future` and `_cancelCompleter.future` will
     /// ever complete.
  -  final _cancelCompleter = Completer<void>();
  +  /// Set to `null` when [_inner] is completed, because then it's
  +  /// guaranteed that this completer will never complete.
  +  Completer<void>? _cancelCompleter = Completer<void>();
   
     /// The callback to call if the operation is canceled.
     final FutureOr<void> Function()? _onCancel;
   
  +  /// Whether [complete] or [completeError] may still be called.
  +  ///
  +  /// Set to false when calling either.
  +  ///
  +  /// When completing by calling [complete] with a future,
  +  /// it's still possible to cancel until the result is actually
  +  /// available.
  +  /// You are also allowed to call [complete] or [completeError]
  +  /// after the operation has been canceled, as long as you only call it once.
  +  /// It just won't do anything after the operation is cancelled.
  +  /// This value only guards the calls to [complete] and [completeError].
  +  bool _mayComplete = true;
  +
     /// The operation controlled by this completer.
     late final operation = CancelableOperation<T>._(this);
  -
  -  /// Set when [complete] or [completeError] is called.
  -  ///
  -  /// Completing twice is not allowed.
  -  ///
  -  /// If [complete] is called with a future, it's still possible to
  -  /// cancel the operation until that future completes,
  -  /// so this value and [_isCanceled] are not mutually exclusive.
  -  bool _isCompleted = false;
  -
  -  /// Set when [cancel] is called.
  -  ///
  -  /// Cancelling twice does nothing, nor does completing after cancelling.
  -  bool _isCanceled = false;
   
     /// Creates a new completer for a [CancelableOperation].
     ///
  
positive.code:   /// has been called once.
    /// The [isCompleted] is true when either of these methods have been called.
    void complete([FutureOr<T>? value]) {
      if (_isCompleted) throw StateError('Operation already completed');
      _isCompleted = true;
  
      if (value is! Future<T>) {
        if (_isCanceled) return;
        _inner.complete(value);
        return;
      }
  
      if (_isCanceled) {
        // Make sure errors from [value] aren't top-leveled.
        value.ignore();
        return;
      }
  
      value.then((result) {
        if (_isCanceled) return;
        _inner.complete(result);
      }, onError: (Object error, StackTrace stackTrace) {
        if (_isCanceled) return;
        _inner.completeError(error, stackTrace);
      });
    }
  
    /// Completes [operation] with [error] and [stackTrace].
  
negative.code:   /// This future will not complete if the operation is cancelled.
    /// Use [valueOrCancellation] for a future which completes
    /// both if the operation is cancelled and if it isn't.
    Future<T> get value => _completer._inner?.future ?? Completer<T>().future;
  
    /// Creates a [Stream] containing the result of this operation.
    ///
  