Bound mismatch error and java generic method

前端 未结 5 1541
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 00:32

I am getting the following error:

Bound mismatch: The generic method constructPage(WebDriver, int, Class) of type     
Page is not applicab         


        
5条回答
  •  萌比男神i
    2021-01-06 01:01

    The problem is that HomePage is a Page and not a Page. The login method would return a Page from its generic signature.

    You must make the generic parameter of HomePage related to itself, not SecuredPage. This will resolve the compiler error. Keep SecuredPage generic, but make sure its bound extends SecuredPage. Then assign HomePage itself for the generic parameter T in HomePage.

    class SecuredPage> extends Page {
    ...
    }
    class HomePage extends SecuredPage  {
    ...
    }
    

提交回复
热议问题