Change record status: 
Project: 
Introduced in branch: 
8.0.x
Description: 

Previously, context value objects were mutable, and provided a setContextValue() method.

In order to make them immutable, three changes were made.

First, the setContextValue() method was removed from both \Drupal\Core\Plugin\Context\ContextInterface and \Drupal\Component\Plugin\Context\ContextInterface

Second, the ability to set a value was added to the constructor, as the second parameter. This is optional as to not break BC.

Third, because \Drupal\Core\Plugin\Context\ContextInterface also tracks cacheable metadata associated with a given context value, that information should be preserved when replacing a context object. Therefore a method was added to ContextInterface:
public static function createFromContext(ContextInterface $old_context, $value);
Usage:
Old code

function whatever(ContextInterface $some_context) {
  $some_context->setContextValue('some new value');
  return $some_context;
}

New code

function whatever(ContextInterface $some_context) {
  $context = Context::createFromContext($some_context, 'some new value');
  return $context;
}
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done