I ran into the following problem:
I have class and interface definitions
public abstract class ViewModelRefreshPostListFragment<T extends IRefreshPostViewCallback, R extends RefreshPostViewModel<T>> extends RefreshPostListFragment implements IRefreshPostView { private final ViewModelHelper<T, R> mViewModeHelper =
Eclipse gives me this error: Associated mismatch: Type R not a valid replacement for the limited parameter <R extends AbstractViewModel<T>> type ViewModelHelper<T,R>
Based on Java inheritance, I created these two chains:
The chain from the definition of the ViewModelRefreshPostListFragment class
1) R extends RefreshPostViewModel<T> → R extends RefreshPostViewModel<R1 extends IRefreshPostViewCallback> → R extends AbstractViewModel<IRefreshPostViewCallback>
1.1) T extends IRefreshPostViewCallback
1.2) T (from RefreshPostViewModel<T> ) is replaced by <R1 extends IRefreshPostViewCallback> specific result is from 1.1) and 1.2), so the parameter T should be in order.
Chain from ViewModelHelper Class Definition
2) R extends AbstractViewModel<T>
2.1) T extends IView IRefreshPostViewCallback extends IView , IRefreshPostViewCallback extends IView → T can be replaced with IRefreshPostViewCallback
If I apply 2.1) to 1.1) && 1.2), we see that the parameter T is consistent
From 1) it follows R extends AbstractViewModel<IRefreshPostViewCallback> from 2) it follows R extends AbstractViewModel<T> , and from 2.1) it follows that T can be replaced by IRefreshPostViewCallback , If I understand correctly, this error should not appear, can someone explain me, why does the eclipse give me an error ??
Thanks!
source share