https://kotlinlang.org logo
#spring
Title
# spring
s

Sourabh Rawat

02/25/2022, 10:46 AM
Why does
Copy code
@Component
class Foo {
    inline fun foo() {}
}
gives me
inline' modifier is not allowed on virtual members. Only private or final members can be inlined
s

Sam

02/25/2022, 11:00 AM
Perhaps you're using the Kotlin Spring compiler plugin? That will make
@Component
classes and their public members
open
by default, to allow Spring to do its thing. That would explain why
foo
is not being treated as a
final
function.
s

Sourabh Rawat

02/25/2022, 11:02 AM
Yea, that seems to be the case. But I was hoping for finding some way to support inline functions in an open class as well, at least when interacting with spring
s

Sam

02/25/2022, 11:04 AM
Just mark the function as explicitly
final
Copy code
@Component
class Foo {
    final inline fun foo() {}
}
🙏 1
2 Views