amelentev / java-oo

Java Operator Overloading
http://amelentev.github.io/java-oo/
268 stars 31 forks source link

java-oo does not work for class whose superclass is parametrized by generic type #51

Open dapengzhang0 opened 7 years ago

dapengzhang0 commented 7 years ago
public abstract class Abstract {
    static class Base<T> {
        public T add(T a) {
        return a;
    }
    }

    static class Ext extends Base<Integer> {
    }

    public static boolean test() {
        Integer a = new Ext().add(new Integer(1));  // this can compile
        Integer b = new Ext() + new Integer(1);   // this can not compile!
        return true;
    }
}
Running JCPOOTest
Note: Injecting OO to javac8
../tests/Abstract.java:14: error: incompatible types: T cannot be converted to Integer
                Integer b = new Ext() + new Integer(1);  // this can not compile!
                                      ^
  where T is a type-variable:
    T extends Object declared in class Base
1 error