pawegio / KAndroid

Kotlin library for Android
Apache License 2.0
896 stars 81 forks source link

Is there any way to suppress the warning in callsite when using fromApi/toApi? #43

Closed Edward608 closed 7 years ago

Edward608 commented 7 years ago

It is quite annoying to see those unnecessary warnings in the call site of these two inline functions, since the api level check is already done.

pawegio commented 7 years ago

For now the only/best way is to surround function with @TargetApi(..) annotation:

@TargetApi(26)
fun foo() {
    fromApi(26) { /* ... */ }
}

whereas in the call site... I would disable this inpection in IDE:

zrzut ekranu 2017-08-30 o 23 23 29

Hope it will be fixed after better kotlin support.