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

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

Open
dapengzhang0 opened this issue Aug 1, 2017 · 0 comments

Comments

@dapengzhang0
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant