I have the following code in an abstract java class:
protected abstract <E extends HasText & IsWidget> E createNewDisplayWidget();
Which compiles fine. However if I call it anywhere, the compiler complains:
Bound mismatch: The generic method createNewDisplayWidget() of type DemoClass is not applicable for the arguments (). The inferred type HasText is not a valid substitute for the bounded parameter <E extends HasText & IsWidget>
Is there a way to require an abstract method to return something that should implement multiple interfaces?
Note: No, I cannot create a special interface that implements the two I like. GWT has widgets like Label which already implement said interfaces and I would like to use said widget.
Edit: I got the idea to do this from here (page 22):
The problem was in Eclipse. I upgraded from 3.7 to 3.7.2 and the compiler error went away.
I don’t know the details of what effect this had. If someone has a clue please feel free to update my answer.