I have an Android project which calls old java code:
ContactsListActivity.startForResultShare(
this, STATE_MULTISHARE, -1, -1, R.string.global_title_send
)
Far from ideal, I wonder why named arguments are not supported. If I write a small kotlin wrapper around the java call I get them:
// Small wrapper.
@Suppress("NOTHING_TO_INLINE")
inline fun startForResultShare(
activity: Activity, @ContactsState typeOfContactList: Int,
idChatUserPostToShare: Long, idChatToModify: Long, @StringRes title: Int
) {
ContactsListActivity.startForResultShare(
activity, typeOfContactList, idChatUserPostToShare, idChatToModify,
title
)
}
…
// At call site.
startForResultShare(
activity = this, typeOfContactList = STATE_MULTISHARE,
idChatUserPostToShare = -1, idChatToModify = -1,
title = R.string.global_title_send
)
In fact, I guess it would be possible to generate a …Kt.kt version of java files creating named arguments in the spirit of package-level functions when calling Kotlin from Java, at least for static methods, so I could directly write the following without the manual wrapper:
ContactsListActivityKt.startForResultShare(
activity = this, typeOfContactList = STATE_MULTISHARE,
idChatUserPostToShare = -1, idChatToModify = -1,
title = R.string.global_title_send
)
Is this wrapping expensive, or does it have other problems I haven’t encountered yet?