https://kotlinlang.org logo
a

althaf

07/28/2021, 6:08 AM
hi i'm trying to reduce the visibility of an extension written to fragment. So this extension should be only visible at package level.
Copy code
package com.abcd.registration
internal fun 

Fragment.showUserAlreadyRegisteredOnAnotherDevice(actionProceedToRegister: (() -> Unit)?,
                                                               actionCancel: (() -> Unit)?) {
    activity?.supportFragmentManager?.let {
        var alreadyRegisterAnotherDeviceBottomSheet: AlreadyRegisterAnotherDeviceBottomSheet =
                AlreadyRegisterAnotherDeviceBottomSheet.getInstance(
                        actionProceedToRegister,
                        actionCancel)

        alreadyRegisterAnotherDeviceBottomSheet?.show(it, "BottomSheet")
    }
}
I want this to be visible to only registration package any top level package should be able to use this extension even if they are inheriting from Fragment. Is this doable. I added internal keyword, still it is not working here. Any inputs ?
r

rnett

07/28/2021, 6:10 AM
internal
is module-only, there is no package-only modifier in Kotlin (although it's being considered, see https://youtrack.jetbrains.com/issue/KT-29227)
a

althaf

07/28/2021, 6:17 AM
Thank you
t

Tyler Hodgkins

07/28/2021, 7:08 AM
Wow, thanks for linking that YouTrack. Would love to see some additional scoping support in Kotlin, as a library developer it's one of my biggest gripes (I don't have many)