QuickPermissions-Kotlin icon indicating copy to clipboard operation
QuickPermissions-Kotlin copied to clipboard

Use generic return type for runWithPermissions functions.

Open acsbendi opened this issue 5 years ago • 0 comments

This can be useful to preserve the original function's return type. My use case:

interface InterfaceWithUnitMethod{
        fun unitMethod()
}
class MyFragment() : Fragment(), InterfaceWithUnitMethod{
       override fun unitMethod() = runWithPermissions(...){
                ...
       }
}

The override will only work if the return type matches the interface's, that is, Unit. Therefore, the previous Any? return type won't work in this scenario.

acsbendi avatar Feb 24 '20 16:02 acsbendi