readMessage method Null safety

void readMessage(
  1. GeneratedMessage message,
  2. ExtensionRegistry extensionRegistry
)

Implementation

void readMessage(
    GeneratedMessage message, ExtensionRegistry extensionRegistry) {
  var length = readInt32();
  if (_recursionDepth >= _recursionLimit) {
    throw InvalidProtocolBufferException.recursionLimitExceeded();
  }
  if (length < 0) {
    throw ArgumentError(
        'CodedBufferReader encountered an embedded string or message'
        ' which claimed to have negative size.');
  }

  var oldLimit = _currentLimit;
  _currentLimit = _bufferPos + length;
  if (_currentLimit > oldLimit) {
    throw InvalidProtocolBufferException.truncatedMessage();
  }
  ++_recursionDepth;
  message.mergeFromCodedBufferReader(this, extensionRegistry);
  checkLastTagWas(0);
  --_recursionDepth;
  _currentLimit = oldLimit;
}