Stefan Beyer
05/14/2020, 8:50 AMArray<Any?>
. There are helper methods that type juggle the return values like so:
fun Any?.toIntOrZero(): Int = (this as? Long)?.toInt() ?: (this as? Double)?.toInt() ?: 0
This is of course horrible, so I want to deprecate all of these helper functions, so that any developer sees that this is not the right way to do things:
@Deprecated("use the new type safe db repository instead of this manual type-juggling (see readme.md for refactoring advice)")
fun Any?.toIntOrZero(): Int = (this as? Long)?.toInt() ?: (this as? Double)?.toInt() ?: 0
But now there is a warning, that the replaceWith parameter of the deprecation annotation is missing. But there is no simple replacement of this, since every database access needs to be refactored and cleaned up individually. this helper function is just a symptom of the problem, so to speak. So is this ok, just to slap a @Suppress("DeprecatedCallableAddReplaceWith")
in front of this deprecation annotation and call it a day? Or is there a better way to do this?ilya.gorbunov
05/14/2020, 9:09 AMspand
05/14/2020, 9:12 AMspand
05/14/2020, 9:14 AMStefan Beyer
05/14/2020, 9:30 AM