I define an enum that takes a method reference:
enum class Op(val param: (Expression<String>, String) -> Predicate) { GREATER_THAN(CriteriaBuilder::greaterThan) } There are two candidates in the CriteriaBuilder class, and the compiler can't figure out which one I mean ("Overload resolution ambiguity. All these functions match."):
<Y extends Comparable<? super Y>> Predicate greaterThan(Expression<? extends Y> x, Expression<? extends Y> y); <Y extends Comparable<? super Y>> Predicate greaterThan(Expression<? extends Y> x, Y y); Why can't Kotlin infer the right type? Clearly the first method is not possible. I can't figure out how to guide the compiler, casting it to the right type doesn't seem to work:
GREATER_THAN(CriteriaBuilder::greaterThan as (Expression<String>, String) -> Predicate) Compiler complains "Cannot choose among the following candidates without completing type inference".
BiFunctioninterface instead of a Kotlin function type(Expression<String>, String) -> Predicate?CriteriaBuilderinstance in your design? The definition of the enum itself, or the caller ofOp.param?