zt
05/21/2023, 5:04 AMFrancesc
05/21/2023, 5:11 AMHowever, function references also implement function types and can be used as function literals. Such usages are not considered "real" reflection and introduce no performance overhead compared to lambda expressions
ephemient
05/21/2023, 5:14 AMAny::toString.name // "toString"
{ it: Any -> it.toString() }.name // does not compile
Any::toString == Any::toString // true
{ it: Any -> it.toString() } == { it: Any -> it.toString() } // false
but it still does not involve runtime reflectiontoString()
on a lambda or callable reference will cause kotlin-reflect to load metadata which can be slow: https://youtrack.jetbrains.com/issue/KT-54175zt
05/21/2023, 5:44 AMinstance::foo.get()
instance::foo.set("bar")
ephemient
05/21/2023, 6:09 AM"".let(String::length)
), otherwise it involves some machinery that doesn't directly involve runtime reflection or metadata but might access that depending on what calls are made