-------------------- Merging types --------------------
185742
function isOnlyFunction(typ) {
	return typ instanceof TObject && 
		   typ.qname === null && 
		   typ.properties.size() === 0 &&
		   typ.calls.length > 0 &&
		   typ.typeParameters.length === 0 &&
		   typ.supers.length === 0;
}
334452
function merge_objects_(b) {
		if(is.func(b)) {
			b = b();
		}
		debug.assert(b).is('object');
		_merge_object(opts, a, b);
	}
181694
function mergeInto(one, two) {
  checkMergeObjectArg(one);
  if (two != null) {
    checkMergeObjectArg(two);
    for (var key in two) {
      if (!two.hasOwnProperty(key)) {
        continue;
      }
      one[key] = two[key];
    }
  }
}
16184
@Override
    public void merge(WebServiceRef webServiceRef, Class<?> instanceClass, Member member) throws InjectionException {

        mergeWSRInfo(webServiceRef, instanceClass, member);

        // The former value should override the later one, i.e. the settings in DD should override the ones in annotation,
        // but we prefer the subclass.
        Class<?> annoType = webServiceRef.type();
        if (!annoType.getName().equals(Object.class.getName())) {
            Class<?> existingType = loadClass(wsrInfo.getServiceRefTypeClassName());

            if (!existingType.getName().equals(Object.class.getName())) {
                //prefer the subclass
                if (existingType.isAssignableFrom(annoType)) {
                    wsrInfo.setServiceRefTypeClassName(annoType.getName());
                } else if (annoType.isAssignableFrom(existingType)) {
                    wsrInfo.setServiceRefTypeClassName(existingType.getName());
                } else { // conflict
                    String msgKey;
                    Object[] inserts;
                    if (member != null) {
                        msgKey = "error.service.ref.type.mismatch.for.member";
                        inserts = new Object[] { wsrInfo.getJndiName(), member.getName(), member.getDeclaringClass().getName(),
                                                annoType.getName(), existingType.getName() };
                    } else {
                        msgKey = "error.service.ref.type.mismatch.for.class";
                        inserts = new Object[] { wsrInfo.getJndiName(), annoType.getName(), existingType.getName() };
                    }
                    Tr.error(tc, msgKey, inserts);
                    throw new InjectionException(Tr.formatMessage(tc, msgKey, inserts));
                }
            } else {
                wsrInfo.setServiceRefTypeClassName(annoType.getName());
            }
        }

        Class<?> annoValue = webServiceRef.value();
        if (!annoValue.getName().equals(Service.class.getName())) {
            Class<?> existingValue = loadClass(wsrInfo.getServiceInterfaceClassName());

            if (!existingValue.getName().equals(Service.class.getName())) {
                //prefer the subclass
                if (existingValue.isAssignableFrom(annoValue)) {
                    wsrInfo.setServiceInterfaceClassName(annoValue.getName());
                } else if (annoValue.isAssignableFrom(existingValue)) {
                    wsrInfo.setServiceInterfaceClassName(existingValue.getName());
                } else { // conflict
                    String msgKey;
                    Object[] inserts;
                    if (member != null) {
                        msgKey = "error.service.interface.mismatch.for.member";
                        inserts = new Object[] { wsrInfo.getJndiName(), member.getName(), member.getDeclaringClass().getName(), annoValue.getName(),
                                                existingValue.getName() };
                    } else {
                        msgKey = "error.service.interface.mismatch.for.class";
                        inserts = new Object[] { wsrInfo.getJndiName(), annoValue.getName(), existingValue.getName() };
                    }
                    Tr.error(tc, msgKey, inserts);
                    throw new InjectionException(Tr.formatMessage(tc, msgKey, inserts));
                }
            } else {
                wsrInfo.setServiceInterfaceClassName(annoValue.getName());
            }
        }

        // Validate and set value and type
        if (member == null) {
            validateAndSetClassLevelWebServiceRef(instanceClass);
        } else {
            // If the wsrInfo service ref type hasn't been set, the infer it from the member.
            validateAndSetMemberLevelWebServiceRef(member);
        }

        // now check the WSDL locations
        if (webServiceRef.wsdlLocation() != null && !webServiceRef.wsdlLocation().isEmpty()) {
            processExistingWSDL(webServiceRef.wsdlLocation(), member);
        }

        // now check to see if there was an @HandlerChain annotation on this member
        HandlerChain handlerChainInstance = null;
        if (member == null) {
            handlerChainInstance = instanceClass.getAnnotation(HandlerChain.class);
        } else if (member instanceof Field) {
            Field field = (Field) member;
            handlerChainInstance = field.getAnnotation(HandlerChain.class);
        } else if (member instanceof Method) {
            Method method = (Method) member;
            handlerChainInstance = method.getAnnotation(HandlerChain.class);
        }
        if (handlerChainInstance != null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "@HandlerChain annotation found with @WebServiceRef annotation, jndiName: " + webServiceRef.name());
            }
            wsrInfo.setHandlerChainDeclaringClassName(instanceClass.getName());
            wsrInfo.setHandlerChainAnnotation(handlerChainInstance);
        }

    }
618287
private void mergeInto(RootListNode<K, V> head, RootListNode<K, V> tail) {
        // if root list empty, just copy
        if (rootList.head == null) {
            rootList.head = head;
            rootList.tail = tail;
            return;
        }

        // initialize
        RootListNode<K, V> resultHead;
        RootListNode<K, V> resultTail;
        RootListNode<K, V> resultTailPrev = null;
        RootListNode<K, V> cur1 = rootList.head;
        RootListNode<K, V> cur2 = head;

        // add first node
        if (cur1.root.rank <= cur2.root.rank) {
            resultHead = cur1;
            resultTail = cur1;
            RootListNode<K, V> cur1next = cur1.next;
            cur1.next = null;
            cur1 = cur1next;
            if (cur1next != null) {
                cur1next.prev = null;
            }
        } else {
            resultHead = cur2;
            resultTail = cur2;
            RootListNode<K, V> cur2next = cur2.next;
            cur2.next = null;
            cur2 = cur2next;
            if (cur2next != null) {
                cur2next.prev = null;
            }
        }

        // merge
        int rank1, rank2;
        while (true) {
            int resultRank = resultTail.root.rank;

            // read rank1
            if (cur1 != null) {
                rank1 = cur1.root.rank;
            } else {
                if (cur2 != null && cur2.root.rank <= resultRank) {
                    rank1 = Integer.MAX_VALUE;
                } else {
                    break;
                }
            }

            // read rank2
            if (cur2 != null) {
                rank2 = cur2.root.rank;
            } else {
                if (cur1 != null && cur1.root.rank <= resultRank) {
                    rank2 = Integer.MAX_VALUE;
                } else {
                    break;
                }
            }

            if (rank1 <= rank2) {
                switch (Integer.compare(rank1, resultRank)) {
                case 0:
                    // combine into result
                    resultTail.root = combine(cur1.root, resultTail.root);
                    resultTail.root.parent = resultTail;
                    // remove cur1
                    RootListNode<K, V> cur1next = cur1.next;
                    cur1.next = null;
                    if (cur1next != null) {
                        cur1next.prev = null;
                    }
                    cur1 = cur1next;
                    break;
                case -1:
                    // can happen if three same ranks
                    cur1next = cur1.next;
                    // add before tail into result
                    cur1.next = resultTail;
                    resultTail.prev = cur1;
                    cur1.prev = resultTailPrev;
                    if (resultTailPrev != null) {
                        resultTailPrev.next = cur1;
                    } else {
                        resultHead = cur1;
                    }
                    resultTailPrev = cur1;
                    // advance cur1
                    if (cur1next != null) {
                        cur1next.prev = null;
                    }
                    cur1 = cur1next;
                    break;
                case 1:
                    // append into result
                    resultTail.next = cur1;
                    cur1.prev = resultTail;
                    resultTailPrev = resultTail;
                    resultTail = cur1;
                    // remove cur1
                    cur1 = cur1.next;
                    resultTail.next = null;
                    if (cur1 != null) {
                        cur1.prev = null;
                    }
                    break;
                }
            } else {
                // symmetric case rank2 < rank1
                switch (Integer.compare(rank2, resultRank)) {
                case 0:
                    // combine into result
                    resultTail.root = combine(cur2.root, resultTail.root);
                    resultTail.root.parent = resultTail;
                    // remove cur2
                    RootListNode<K, V> cur2next = cur2.next;
                    cur2.next = null;
                    if (cur2next != null) {
                        cur2next.prev = null;
                    }
                    cur2 = cur2next;
                    break;
                case -1:
                    // can happen if three same ranks
                    cur2next = cur2.next;
                    // add before tail into result
                    cur2.next = resultTail;
                    resultTail.prev = cur2;
                    cur2.prev = resultTailPrev;
                    if (resultTailPrev != null) {
                        resultTailPrev.next = cur2;
                    } else {
                        resultHead = cur2;
                    }
                    resultTailPrev = cur2;
                    // advance cur2
                    if (cur2next != null) {
                        cur2next.prev = null;
                    }
                    cur2 = cur2next;
                    break;
                case 1:
                    // append into result
                    resultTail.next = cur2;
                    cur2.prev = resultTail;
                    resultTailPrev = resultTail;
                    resultTail = cur2;
                    // remove cur2
                    cur2 = cur2.next;
                    resultTail.next = null;
                    if (cur2 != null) {
                        cur2.prev = null;
                    }
                    break;
                }
            }
        }

        // record up to which point a suffix minimum update is needed
        RootListNode<K, V> updateSuffixFix = resultTail;

        // here rank of cur1 is more than result rank
        if (cur1 != null) {
            cur1.prev = resultTail;
            resultTail.next = cur1;
            resultTail = rootList.tail;
        }

        // here rank of cur2 is more than result rank
        if (cur2 != null) {
            cur2.prev = resultTail;
            resultTail.next = cur2;
            resultTail = tail;
        }

        // update suffix minimum
        updateSuffixMin(updateSuffixFix);

        // store final list
        rootList.head = resultHead;
        rootList.tail = resultTail;
    }
491797
@Override
  public void merge(MergeState mergeState) throws IOException {
    final List<Fields> fields = new ArrayList<>();
    final List<ReaderSlice> slices = new ArrayList<>();

    int docBase = 0;

    for (int readerIndex = 0; readerIndex < mergeState.fieldsProducers.length; readerIndex++) {
      final FieldsProducer f = mergeState.fieldsProducers[readerIndex];

      final int maxDoc = mergeState.maxDocs[readerIndex];
      f.checkIntegrity();
      slices.add(new ReaderSlice(docBase, maxDoc, readerIndex));
      fields.add(f);
      docBase += maxDoc;
    }

    Fields mergedFields = new MappedMultiFields(mergeState,
        new MultiFields(fields.toArray(Fields.EMPTY_ARRAY),
            slices.toArray(ReaderSlice.EMPTY_ARRAY)));
    write(mergedFields);
  }
1175306
public void addSubtype(String subtype) {
    if(!StringUtils.isBlank(subtype) && !subtypes.contains(subtype.trim())) {
      subtypes.add(subtype.trim());
    }
  }
272774
function merge(target, source) {
    if (source === null) {
        return target
    }
    var props = Object.getOwnPropertyNames(target)
    props.forEach(function (name) {
        var s = gettype(source[name])
        if (s !== 'undefined') {
            var t = gettype(target[name])
            if (t !== s) {
                throw new Error(`Type mismatch between '${t}' and '${s}' for '${name}'`)
            }
            if (t === 'object') {
                merge(target[name], source[name])
            } else {
                target[name] = source[name]
            }
        }
    })
    return target
}
751766
public void merge(Object obj) {
        if (obj == null) {
            throw new IllegalArgumentException(
                    "Object to merge cannot be null");
        }

        m_properties.putAll(getPropertyMap(obj));
    }
1214315
@Override
	public void addType(int pos, Class<? extends Value> type) throws ConflictingFieldTypeInfoException {
		if (pos == schema.size()) {
			// right at the end, most common case
			schema.add(type);
		} else if (pos < schema.size()) {
			// in the middle, check for existing conflicts
			Class<? extends Value> previous = schema.get(pos);
			if (previous == null) {
				schema.set(pos, type);
			} else if (previous != type) {
				throw new ConflictingFieldTypeInfoException(pos, previous, type);
			}
		} else {
			// grow to the end
			for (int i = schema.size(); i <= pos; i++) {
				schema.add(null);
			}
			schema.set(pos, type);
		}
	}
796958
public void mergeWith(Core o) {
    o.num = this.num = (num < o.num ? num : o.num);
  }
269399
@Override
	public void addType(int key, Class<? extends Key<?>> type) throws ConflictingFieldTypeInfoException  {
		Class<? extends Key<?>> previous = this.schema.put(key, type);
		if (previous != null && previous != type) {
			throw new ConflictingFieldTypeInfoException(key, previous, type);
		}
	}
168392
function merge(a, b) {
  if (type(a) !== type(b)) {
    throw new Error('Incompatible merge scenario.');
  } else if ('object' === type(a)) {
    return mergeObject(a, b);
  } else if ('array' === type(a)) {
    return mergeArray(a, b);
  } else {
    throw new Error('Unsupported merge scenario');
  }
}
218989
function mergeDoctype( elem ) {
		merge( elem, function( old ) {
			utils.replaceElement( old, elem );
			destChildren[ destChildren.indexOf( old ) ] = elem;
		} );
	}
1162031
function mergeTypes(env, types, conf, ENV, fn) {
  fetch(conf, 'types', function(err, layout) {
    if (err) return fn(err);
    debug('# TYPES');

    var batch = new Batch();

    batch.concurrency(1);

    types.forEach(function(type) {
      batch.push(function(cb) {
        debug(type);
        mergeConf(env, layout, type, ENV, cb);
      });
    });

    batch.end(fn);
  });
}
1011571
public void merge(SrcTree srcTree) {
        mergeTestClassTable(srcTree.rootClassTable, rootClassTable);
        mergeTestClassTable(srcTree.subClassTable, subClassTable);
        mergeTestMethodTable(srcTree.rootMethodTable, rootMethodTable);
        mergeTestMethodTable(srcTree.subMethodTable, subMethodTable);
        mergeTestFieldTable(srcTree.fieldTable, fieldTable);
    }
1369423
function merge (target, source) {
  if (isMergeable(source)) {
    var keys = Object.keys(source);
    for (var i = 0; i < keys.length; i++) {
      var key = keys[i];
      var sourceSetting = source[key];
      var targetSetting = target[key];

      if (isMergeable(sourceSetting)) {
        // It's a nested object, so merge it recursively
        target[key] = merge(targetSetting || {}, sourceSetting);
      }
      else if (sourceSetting !== undefined) {
        // It's a scalar value, function, or array. No merging necessary. Just overwrite the target value.
        target[key] = sourceSetting;
      }
    }
  }
  return target;
}