Is not being able to call extension class methods ...
# announcements
m
Is not being able to call extension class methods from another class (https://youtrack.jetbrains.com/issue/KT-24290) design choice or shortcoming of the compiler? It makes class methods that extend
CoroutineScope
(needed by convention) quite awkward to call.
2
l
You can use
with
to have a second receiver.
m
yes, but it makes it a bit awkward
instead of simple
someObject.call()
I have to do
with(someObject) { call() }
l
There's no better solution, apart from getting rid of the class (top-level) or the receiver (
suspend
)
p
How do I fix this, for instance? https://pl.kotl.in/2ihLqKfqT
l
@pavi2410 I just said how. Make the extension top-level. Putting that into an object is a Java statics habit that is not needed in Kotlin. You can also get rid of the
Context
receiver by using the top level
appCtx
property I developed here: https://github.com/LouisCAD/Splitties/tree/master/modules/appctx