Access to member extension function

I want to make a library like this

class SomeClass{
    fun IScript.someFun(): ReadWriteProperty<*,*> {TODO()}
}
fun getClass()=SomeClass()

and a script context based on IScript

val someVar by getClass().somefun()

but i must do like this

interface IScript
class SomeClass{
    fun IScript.someFun(): ReadWriteProperty<*,*> {TODO()}
}
fun getClass()=SomeClass()
(object:IScript).apply {
    val someVar by getClass().run { someFun() }
}

I would like to know whether it is a design or a bug

I don’t think you understand what you wrote. When you say this:

You are declaring that someFun() must be applied to an IScript within the context of a SomeClass.

Then you say that you want to write this:

But there’s nothing in there that could provide the IScript that you need to call someFun on.

1 Like

a script context based on IScript

or you can see the last example(use (object:IScript).apply {} mock a script context)