You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the View, PresenterWidget, OrderedSlot, UIHandlers, ViewWithUiHandlers emulate existing GWTP classes.
I have added a custom base presenter class BasePresenter which is generic in the UIHandlers and the ViewWithUiHandlers. It also is Comparable to itself.
Now, in order for another Presenter to have a Slot that accepts presenters extending this base class, I would need to following OrderedSlot declaration:
/home/boris/.../App.java
Error:Error:line (6)java: type argument com.example.testbench.App.BasePresenter<?,?> is not within bounds of type-variable T
Error:Error:line (6)java: incompatible types: cannot infer type arguments for com.example.testbench.App.OrderedSlot<>
reason: inferred type does not conform to equality constraint(s)
inferred: com.example.testbench.App.BasePresenter<capture#1 of ?,capture#2 of ?>
equality constraints(s): com.example.testbench.App.BasePresenter<capture#1 of ?,capture#2 of ?>,com.example.testbench.App.BasePresenter<?,?>
This is because the compiler cannot find type bounds on the wildcards ?, ? such that the self type & Comparable<T> is satisfied. And this makes sense, as if I create two extension classes and add them both to the OrderedSlot<BasePresenter<?, ?>>
Then as PresenterOne implements Comparable<BasePresenter<SomeUiHandlers, ViewWithUiHandlers<SomeUiHandlers>> and PresenterTwo implements Comparable<BasePresenter<OtherUiHandlers, ViewWithUiHandlers<OtherUiHandlers>> the type equality constraint is violated.
In order for this situation to work, the type constraint on OrderedSlot needs to be relaxed.
The text was updated successfully, but these errors were encountered:
OrderedSlot
should probably have the following signature:This is because it is currently impossible to have a common generic baseclass for widgets that need to be members of an
OrderedSlot
.Consider the following example (sorry, it's quite horrible):
So the
View
,PresenterWidget
,OrderedSlot
,UIHandlers
,ViewWithUiHandlers
emulate existing GWTP classes.I have added a custom base presenter
class BasePresenter
which is generic in theUIHandlers
and theViewWithUiHandlers
. It also isComparable
to itself.Now, in order for another
Presenter
to have aSlot
that accepts presenters extending this base class, I would need to followingOrderedSlot
declaration:But this will result in a compiler error:
This is because the compiler cannot find type bounds on the wildcards
?, ?
such that the self type& Comparable<T>
is satisfied. And this makes sense, as if I create two extension classes and add them both to theOrderedSlot<BasePresenter<?, ?>>
Then as
PresenterOne implements Comparable<BasePresenter<SomeUiHandlers, ViewWithUiHandlers<SomeUiHandlers>>
andPresenterTwo implements Comparable<BasePresenter<OtherUiHandlers, ViewWithUiHandlers<OtherUiHandlers>>
the type equality constraint is violated.In order for this situation to work, the type constraint on
OrderedSlot
needs to be relaxed.The text was updated successfully, but these errors were encountered: