Support for generics in short method declarations

Issue #208 invalid
Jon Sten created an issue

Short method declarations (not 100% sure that that is the name) is a really nice feature in JastAdd, i.e:

public void A.b(Object o, Collection<Object> res) {
  ...
}

Unfortunately JastAdd does not support generic methods. I.e. I get parse error for the following:

public <T extends C> void A.b(T o, Collection<T> res) {
  ...
}

The workaround is to write:

public class A {
    public <T extends C> void b(T o, Collection<T> res) {
       ...
    }
}

Unfortunately this introduces some other problems, such as different class declaration signatures for A. I thing that this would be a really nice feature for JastAdd!

Comments (5)

  1. Jesper Öqvist

    I added a test case for this, but it seems that it works. Here is my test case:

    Test.ast:

    A;
    

    Test.jrag:

    import java.util.Collection;
    
    aspect Test {
            public <T extends Integer> void A.b(T o, Collection<T> res) {
            }
    }
    

    Generated code:

    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.11-2-g0090244 */
    import java.util.Collection;
    /**
     * @ast node
     * @declaredat tests/aspect/generics_01p/Test.ast:1
     * @production A : {@link ASTNode};
    
     */
    public class A extends ASTNode<ASTNode> implements Cloneable {
            /**
             * @aspect Test
             * @declaredat tests/aspect/generics_01p/Test.jrag:4
             */
            public <T extends Integer> void b(T o, Collection<T> res) {
            }
    
    ...
    
  2. Jesper Öqvist

    Which version of JastAdd2 do you have this problem in? Is it reproducible in version 2.1.11+?

  3. Jon Sten reporter

    Well that was embarrassing, upgraded to 2.1.11 (from 2.1.5) and it works fine :) Thank you for the help!

  4. Log in to comment