Missing support for writing generic-less code


Now this may sound ridiculous. Why would one want to use e.g. List instead of List<String>? Please let me explain.
I am trying to call the JPA API CriteriaBuilder.greaterThanOrEqualTo, which has the following signature:

<Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Y y);

However, the value of Y is computed dynamically, based on the Class of the target field. Generally, one may use java.util.Date but has to use LocalDate when the JPA field is of type LocalDate, not important. I have a function returning Comparable<*> since there is no other supertype of Date and LocalDate than Comparable.

And here’s the issue: I can’t find a way to cast Comparable<*> to Comparable<Y>. In Java, one can cast to Comparable and suppress the warnings, yet in Kotlin I can’t do that. What should I do? Thanks! :slight_smile:


Currently “solved” this by moving the greaterThanOrEqualTo code to the function, which then returns something else. In particular:

Before, the toFilter() function returned Comparable<*>, now it directly returns JPAFilter.