Mark
08/11/2021, 1:47 PMif
condition (at least 3 branches) where the checks are things like Build.VERSION.SDK_INT > 12
and then branch depends on such a later SDK level. How to suppress this warning?
Thread in Slack ConversationMark
08/12/2021, 8:28 AMkenkyee
08/12/2021, 10:11 AMMark
08/12/2021, 10:15 AMswitch
statement?kenkyee
08/12/2021, 10:22 AMMark
08/12/2021, 10:25 AMwhen
statement showing a compilation error when the equivalent if
statement does not. How do you propose you write this in Java to get the same error?
val capture = when {
Build.VERSION.SDK_INT < Build.VERSION_CODES.R -> "fallback"
else -> requires30() // compile-time error "Call requires API level 30 (current min is 23): requires30"
}
@RequiresApi(30)
fun requires30() {}
In other words, I think this is specifically to do with the (Lint perhaps) parsing of the when
statement in Kotlin, rather than some language-independent thing.kenkyee
08/12/2021, 11:49 AMMark
08/12/2021, 12:43 PM