Reputation: 83853
I have a static method declared in Java:
class X {
public static void foo(Y y) { … }
}
I would love to use this method as extension method for instances of type Y
in Kotlin:
import X.foo
…
y.foo()
Is that possible? I have control over all source code in question, e.g. to add annotations.
Upvotes: 6
Views: 320
Reputation: 31690
I don't know of a way to automatically refer to these, but writing your own extension that just wraps the existing method should be possible...
fun Y.foo() = X.foo(this)
Upvotes: 8