Majkeee
Majkeee

Reputation: 1292

ChecksSdkIntAtLeast is not working properly

I am trying to use @ChecksSdkIntAtLeast annotation to convert our java utility functions into kotlin properties that would not require @SuppressLint("NewApi").

But anyway I write the property, it stops red underlining code for both branches of if.

Demo:

@get:ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
val isAtLeastOreo: Boolean
    get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    manager.getNotificationChannel("general")
} else {
    manager.getNotificationChannel("general")        // CORRECTLY UNDERLINED
}

if (isAtLeastOreo) {
    manager.getNotificationChannel("general")
} else {
    manager.getNotificationChannel("general")        // NOT UNDERLINED - WHY??
}

Same thing happens if I make it into function instead of getter. The only working one would be using lambda, but then I am losing if-else construct and would require massive amount of places to refactor.

Upvotes: 1

Views: 794

Answers (1)

Majkeee
Majkeee

Reputation: 1292

Issue has been reported on Aug 23. Waiting for response

https://issuetracker.google.com/issues/197428342

Upvotes: 2

Related Questions