Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Adding wildcards to 1.5 branch



Still not done with wildcards, though making progress...
We still reject the following program, which we shouldn't...

public class X <T> {
    T t;
    X(T t){
        this.t = t;
    }
    public static void main(String[] args) {
            X<? extends AX> x = new X<AX<String>>(new AX<String>());
            x.t.foo();
            System.out.println("SUCCESS");
      }
}

class AX<P> {
    P foo() { return null; }
}




----------
1. ERROR in d:\eclipse\workspaces\dev3.0-1.5\plugins\Crap\src\X.java (at
line 7)
      X<? extends AX> x = new X<AX<String>>(new AX<String>());
                      ^
Type mismatch: cannot convert from X<AX<String>> to X<? extends AX>
----------
2. ERROR in d:\eclipse\workspaces\dev3.0-1.5\plugins\Crap\src\X.java (at
line 8)
      x.t.foo();
          ^^^
The method foo() is undefined for the type ? extends AX
----------
2 problems (2 errors)



Back to the top