anchor.diff:    }
   
     String? emitSubscriptedVar(int depth, DartType tp,
  -      {bool isLhs = false, RhsFilter? rhsFilter}) {
  +      {bool isLhs = false, String? assignOp, RhsFilter? rhsFilter}) {
       String? ret;
       // Check if type tp is an indexable element of some other type.
       if (dartType.isIndexableElementType(tp)) {
         // Select a list or map type that contains elements of type tp.
  -      final iterType = oneOfSet(dartType.indexableElementTypes(tp));
  +      var iterType = oneOfSet(dartType.indexableElementTypes(tp));
  +      // For `collection[key] <op>= value` to work, collection must not be a
  +      // Map or Expando because their subscript operators return a nullable
  +      // type.
  +      if (assignOp != null && assignOp != "=") {
  +        while (!DartType.isListType(iterType)) {
  +          iterType = oneOfSet(dartType.indexableElementTypes(tp));
  +        }
  +      }
         // Get the index type for the respective list or map type.
         final indexType = dartType.indexType(iterType);
         // Emit a variable of the selected list or map type.
  
positive.code:   }
  
    String? emitVar(int depth, DartType tp,
        {bool isLhs = false, RhsFilter? rhsFilter}) {
      switch (choose(2)) {
        case 0:
          return emitScalarVar(tp, isLhs: isLhs, rhsFilter: rhsFilter);
          break;
        default:
          return emitSubscriptedVar(depth, tp,
              isLhs: isLhs, rhsFilter: rhsFilter);
          break;
      }
    }
  
negative.code:     }
      emitIndentation();
      // Emit a variable of the lhs type.
      final emittedVar = emitVar(0, tp, isLhs: true, assignOp: assignOp)!;
      var rhsFilter = RhsFilter.fromDartType(tp, emittedVar);
      emit(' $assignOp ');
      // Select one of the possible rhs types for the given lhs type and assign
  