Problem with a Java class function named 'in' (CQEngine)


#1

Hi, I’m using CQEngine from Kotlin and it has a static import on a function named ‘in’.

If I try to use this in Kotlin I get the following error (from IntelliJ and on compilation): “Expecting an element” - I guess because ‘in’ is a reserved word.

A Java example is here: https://github.com/npgall/cqengine/blob/master/code/src/test/java/com/googlecode/cqengine/query/simple/InTest.java

Any idea how I can properly call the ‘in’ method from Kotlin?


#2

As documented here you need to escape the method name using backticks.


#3

Thank you - spent a whole morning Googling for exactly this and didn’t come across it!


#4

You need to escape it with back-ticks:

 class X {
        fun `in`() { }
    }

    fun t(x: X) {
        x.`in`()
    }