The class used (in Java, third party API, not changeable):
public class BookmarkablePageLink<T> extends Link<T> {
public <C extends Page> BookmarkablePageLink(final String id, final Class<C> pageClass)
And now I want to call this from Kotlin:
item.queue(BookmarkablePageLink("link", bookmark.page))
bookmark.page
is in Java, and it is: public Class<? extends WebPage> getPage()
None of these work:
item.queue(BookmarkablePageLink("link", bookmark.page))
Error: Not enough information to infer parameter T in
constructor Bookmarkable PageLink<T : Any!, C : Page!>(...)
item.queue(BookmarkablePageLink<>("link", bookmark.page))
item.queue(BookmarkablePageLink<Any>("link", bookmark.page))
item.queue(BookmarkablePageLink<Any, *>("link", bookmark.page))
item.queue(BookmarkablePageLink<Any, WebPage>("link", bookmark.page))
item.queue(BookmarkablePageLink<Any, in WebPage>("link", bookmark.page))
item.queue(BookmarkablePageLink<Any, out WebPage>("link", bookmark.page))
item.queue(BookmarkablePageLink<Any, T : WebPage>("link", bookmark.page))
This would be the "hypothetically correct" way to do this in Javaish-speak (just the intention, but it's not real code), but this isn't supported by Kotlin:
item.queue(BookmarkablePageLink<Any, ? extends WebPage>("link", bookmark.page))
My best workaround is this, which is ugly, but works:
item.queue(BookmarkablePageLink<Any, WebPage>("link", bookmark.page as Class<WebPage>))
Surprisingly in Java this was simply:
item.queue(new BookmarkablePageLink<>("link", bookmark.getPage() ));
<Any, T : WebPage>
– SavdeepUnresolved reference: T
thenUnexpected type specification
– EndoragetParams
type? – Justuspublic BookmarkablePageLink(final String id, final Class<? extends Page> pageClass)
works – Glochidiumitem.queue<WebPage>(BookmarkablePageLink("link", bookmark.page))
should work. – Glochidium