1

Eclipse is currently triggering this error:

Bound mismatch: The type V is not a valid substitute for the bounded parameter <V extends View<? extends Controller<V>>> of the type Controller<V>

however compilation and running work fine (no errors with IntelliJ and javac). Should I suppress it or is there a simple workaround to allow not triggering the error?

The error is triggered in the of method of the View interface

Thanks

Relevant code:

public interface View<C extends Controller<? extends View<C>>> {
    void setController(C controller);
    void show();
    void hide();
    void close();

    String getViewName();
    String getWindowTitle();

    /**
     * Create a factory for a view.
     *
     * @param viewInterface The view interface to create the factory for.
     * @param <V>           The view interface.
     * @return The factory for the view.
     */
    static <V extends View<? extends Controller<V>>> ViewFactory<V> of(final Class<V> viewInterface) {
        return new ViewFactory<V>().fromInterface(viewInterface);
    }
}

public interface Controller<V extends View<? extends Controller<V>>> {
    void registerView(V view);
    void unregisterView();
    void showView();
    void hideView();
    void closeView();

    /**
     * Create a factory for a controller.
     *
     * @param controllerInterface The controller interface to create the factory for.
     * @param <C>                 The controller interface.
     * @param <V>                 The view interface.
     * @return The factory for the controller.
     */
    static <C extends Controller<V>, V extends View<C>> ControllerFactory<C, V> of(final Class<C> controllerInterface) {
        return of(controllerInterface, null);
    }

    /**
     * Create a factory for a controller.
     *
     * @param controllerInterface The controller interface to create the factory for.
     * @param viewInterface       The view interface to create the factory for.
     * @param <C>                 The controller interface.
     * @param <V>                 The view interface.
     * @return The factory for the controller.
     */
    static <C extends Controller<V>, V extends View<C>> ControllerFactory<C, V> of(final Class<C> controllerInterface, final Class<V> viewInterface) {
        // ...
    }
}

public class ViewFactory<V extends View<? extends Controller<V>>> {
    // ...
}
maicol07
  • 199
  • 1
  • 6
  • 16
  • Can you try to replace the type of the method with: `>>`? I don't have eclipse to test it but it might solve the ambiguity – Alexandru Severin Aug 09 '22 at 08:38
  • @AlexandruSeverin no, with this one it gives the following: `Syntax error on token "extends", , expected` (the "extends" it refers to is in the View generic) – maicol07 Aug 09 '22 at 11:26

0 Answers0