there isnt a way to have `inline` within `interfac...
# announcements
e
there isnt a way to have
inline
within
interface
methods?
only private or final methods can have it
k
How would that work? The compiler needs to know the actual implementation.
e
I'd be fine if I could declare it as final
e
You basically can't declare
interface
method as
final
e
exactly, so there is no way, isn't?
e
You can write an extension function on your interface.
👍 2
e
To clarify, why do you actually need to declare an interface method
inline
?
e
for performances and since I have a lambda in the arguments it makes sense
e
No it doesn't. Should your call with lambda be inlined or not depends on implementation of that method
e
that's the thing, I don't want implement that method
I'm perfectly fine with the common base method
e
I don't understand. So you have an interface with default implementation that you don't want to override and which operates on abstract properties of that interface, right?
e
Copy code
abstract class GLCanvas {

    ...

    @Throws(AWTException::class)
    abstract fun lock()

    @Throws(AWTException::class)
    abstract fun unlock()

    @Throws(AWTException::class)
    inline fun <R> lock(block: () -> R): R =
            try {
                lock()
                block()
            } finally {
                unlock()
            }
}
k
You can just make that an extension function.
e
.. yes
yeah, I know, I tried and worked flawless. However I found that I also have a common property.. that's why I switched to
abstract class
k
...
e
eh sorry 😄