After upgrading from Wicket 7 to Wicket 8, I encounterd multiple erasure warnings in IntelliJ.
E.g. when using AjaxLink IntelliJ complains
'setDefaultModel(IModel model)' in 'org.apache.wicket.MarkupContainer' clashes with 'setDefaultModel(IModel model)' in 'org.apache.wicket.IGenericComponent'; both methods have same erasure yet neither overrides the other
Is there anything I can do about it?
This error occurs when you do not give
AjaxLinka generic type. For example:Instead of something like:
AjaxLink has the following definition:
The ancestor class is
MarkupContainer, which defines:And it implements
IGenericComponent, which has generic types<T, C extends IGenericComponent<? super T, ?>>which are assigned the types<T,AjaxLink<T>>and defines the method:Now, I'm not entirely sure if I fully understand the problem, but somehow due to the lack of generic types, the compiler cannot figure out that the implementation from
MarkupContainer(which returnsMarkupContainer) is covariant with the method defined inIGenericComponent.