'Type inference doesn't work with certain Java generics

There's a class defined as

public class ClickHouseRequest<SelfT extends ClickHouseRequest<SelfT>>

with a method

public SelfT format(ClickHouseFormat format)

The return value of this method is inferred as Any by Scala (but it could be cast to ClickHouseRequest[_]). Is there a way to make Scala infer the return value propery?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source