anchor.diff:          unit = dependentLibrary.units.indexOf(unitElement);
           assert(unit != -1);
         }
  -      LinkedReferenceBuilder linkedReference = new LinkedReferenceBuilder(
  -          dependency: librarySerializer.serializeDependency(dependentLibrary),
  -          kind: _getReferenceKind(element),
  -          unit: unit);
  -      if (element is TypeParameterizedElement) {
  -        linkedReference.numTypeParameters = element.typeParameters.length;
  -      }
  +      ReferenceKind kind = _getReferenceKind(element);
         String name = element == null ? 'void' : element.name;
  +      int index;
  +      LinkedReferenceBuilder linkedReference;
         if (linked) {
  -        linkedReference.name = name;
  +        linkedReference =
  +            new LinkedReferenceBuilder(kind: kind, unit: unit, name: name);
           Element enclosing = element?.enclosingElement;
           if (enclosing is ClassElement) {
             linkedReference.containingReference =
                 _getElementReferenceId(enclosing, linked: linked);
  -          linkedReference.numTypeParameters += enclosing.typeParameters.length;
  -        }
  +          linkedReference.numTypeParameters = enclosing.typeParameters.length;
  +        }
  +        index = linkedReferences.length;
  +        linkedReferences.add(linkedReference);
         } else {
           assert(unlinkedReferences.length == linkedReferences.length);
           int prefixReference = 0;
  
positive.code:     if (name == null) {
        return typeRef;
      } else {
        int typeId = typeRef.reference;
        LinkedReference typeLinkedRef = serializer.linkedReferences[typeId];
        serializer.unlinkedReferences.add(new UnlinkedReferenceBuilder(
            name: name.name, prefixReference: typeId));
        int refId = serializer.linkedReferences.length;
        serializer.linkedReferences.add(new LinkedReferenceBuilder(
            kind: ReferenceKind.constructor, unit: typeLinkedRef.unit));
        return new EntityRefBuilder(
            reference: refId, typeArguments: typeRef.typeArguments);
      }
  
negative.code:     // the element model.  For the moment we use a name that can't possibly
      // ever exist.
      if (unresolvedReferenceIndex == null) {
        return serializeUnlinkedReference(
            '*unresolved*', ReferenceKind.unresolved);
      }
      return unresolvedReferenceIndex;
    }
  