https://kotlinlang.org logo
#android
Title
# android
t

trevjones

04/25/2017, 7:11 PM
it seems the support library resource annotation lints don’t work when used on a vararg param. user error or possible bug/feature request?
Copy code
private fun View.popupMenu(@MenuRes vararg menuItems: Int): PopupMenu {
        return PopupMenu(this.context, this, Gravity.END, 0, R.style.AppTheme_Widget_PopupMenu_Overflow).apply {
            menuItems.forEach { inflate(it) }
            show()
        }
    }
m

mg6maciej

04/25/2017, 7:52 PM
Does it work on vararg in Java?
t

trevjones

04/25/2017, 7:55 PM
good question I will verify. one moment please
it does work in java.
Copy code
public void stuff(@MenuRes int...menuItems) { }
    
public void nothing() {
    stuff(R.anim.design_appbar_state_list_animator, R.layout.demo_mode_playground);
}
m

mg6maciej

04/25/2017, 7:59 PM
Anyway is lint working finally with Kotlin?
What's the status of using UAST?
e

erickoknl

04/25/2017, 8:21 PM
If I remember correctly, it does compile but does not actually correctly constraint the annotation. The IDE won't properly enforce it.
v

vyacheslav.gerasimov

04/26/2017, 8:56 AM
3 Views