code: private FunctionType matchFunction(
        FunctionType expectedType, FunctionType currentType, boolean declared) {
      if (declared) {
        // If the function was declared but it doesn't have a known "this"
        // but the expected type does, back fill it.
        if (currentType.getTypeOfThis().isUnknownType()
            && !expectedType.getTypeOfThis().isUnknownType()) {
          FunctionType replacement =
              FunctionType.builder(registry)
                  .copyFromOtherFunction(currentType)
                  .withTypeOfThis(expectedType.getTypeOfThis())
                  .build();
           return replacement;
        }
      } else {
        // For now, we just make sure the current type has enough
        // arguments to match the expected type, and return the
        // expected type if it does.
        if (currentType.getMaxArity() <= expectedType.getMaxArity()) {
          return expectedType;
        }
      }
      return currentType;
    }
docs: Take the current function type, and try to match the expected function type. This is a form of
  backwards-inference, like record-type constraint matching.
  
  @param declared Whether the given function type is user-provided as opposed to inferred