private FunctionType tryMergeFunctionPiecewise(FunctionType other, boolean leastSuper) {
    Node newParamsNode = null;
    if (call.hasEqualParameters(other.call, EquivalenceMethod.IDENTITY, EqCache.create())) {
      newParamsNode = call.parameters;
    } else {
      // If the parameters are not equal, don't try to merge them.
      // Someday, we should try to merge the individual params.
      return null;
    }

    JSType newReturnType =
        leastSuper
            ? call.returnType.getLeastSupertype(other.call.returnType)
            : call.returnType.getGreatestSubtype(other.call.returnType);

    JSType newTypeOfThis = null;
    if (isEquivalent(typeOfThis, other.typeOfThis)) {
      newTypeOfThis = typeOfThis;
    } else {
      JSType maybeNewTypeOfThis =
          leastSuper
              ? typeOfThis.getLeastSupertype(other.typeOfThis)
              : typeOfThis.getGreatestSubtype(other.typeOfThis);
      newTypeOfThis = maybeNewTypeOfThis;
    }

    boolean newReturnTypeInferred = call.returnTypeInferred || other.call.returnTypeInferred;

    return builder(registry)
        .withParamsNode(newParamsNode)
        .withReturnType(newReturnType, newReturnTypeInferred)
        .withTypeOfThis(newTypeOfThis)
        .build();
  }
private FunctionType tryMergeFunctionPiecewise ( FunctionType other , boolean leastSuper ) { Node newParamsNode = null ; if ( call . hasEqualParameters ( other . call , EquivalenceMethod . IDENTITY , EqCache . create ( ) ) ) { newParamsNode = call . parameters ; } else { return null ; } JSType newReturnType = leastSuper ? call . returnType . getLeastSupertype ( other . call . returnType ) : call . returnType . getGreatestSubtype ( other . call . returnType ) ; JSType newTypeOfThis = null ; if ( isEquivalent ( typeOfThis , other . typeOfThis ) ) { newTypeOfThis = typeOfThis ; } else { JSType maybeNewTypeOfThis = leastSuper ? typeOfThis . getLeastSupertype ( other . typeOfThis ) : typeOfThis . getGreatestSubtype ( other . typeOfThis ) ; newTypeOfThis = maybeNewTypeOfThis ; } boolean newReturnTypeInferred = call . returnTypeInferred || other . call . returnTypeInferred ; return builder ( registry ) . withParamsNode ( newParamsNode ) . withReturnType ( newReturnType , newReturnTypeInferred ) . withTypeOfThis ( newTypeOfThis ) . build ( ) ; }
Try to get the sup/inf of two functions by looking at the piecewise components.