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

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: cqengine/InTest.java at master · npgall/cqengine · GitHub

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

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

1 Like

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

You need to escape it with back-ticks:

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

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