Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit PolyNull to take an argument #54

Closed
GoogleCodeExporter opened this issue Jul 3, 2015 · 1 comment
Closed

Permit PolyNull to take an argument #54

GoogleCodeExporter opened this issue Jul 3, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

It would be nice for PolyNull to take an optional argument, so that
multiple different instantiations of PolyNull can be used in a single
method.  The need for this is very rare, but here is a concrete example:


  /** Returns an array of Strings, where the strings are the result of
   * invoking x.getClass().toString() for each element x in the
   * array. If an element of the array is null, its slot in the returned
   * array is null.
   */
  public static
  @PolyNull("elt") String @PolyNull("container") []
  typeArray(@PolyNull("elt") Object @PolyNull("container") [] seq) {
    if (seq == null) { return null; }
    @PolyNull("elt") String[] retval = new @PolyNull("elt") String[seq.length];
    for (int i = 0 ; i < seq.length ; i++) {
      if (seq[i] == null) {
        retval[i] = null;
      } else {
        retval[i] = seq[i].getClass().toString();
      }
    }
    return retval;
  }

Original issue reported on code.google.com by michael.ernst@gmail.com on 12 Jan 2010 at 5:21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants