WAI
Status Update
Comments
uc...@google.com <uc...@google.com>
tn...@google.com <tn...@google.com> #2
Sorry, this issue fell off the radar, until somebody pointed to it (from
Looking at the code, I don't see a bug here. Lint shouldn't be flagging anything in these code snippets. This is simply a declaration of a typedef, and constants allowed to be used for this type.
Lint should only flag a warning if this is used in some incorrect way. For example, if I add this to the JAva snippet:
@DangerousFace long test1 = 3;
@DangerousFace long test2 = FLAG_1;
or in the Kotlin file,
@get:DangerousFace var test1: Long = 3
@get:DangerousFace var test2 = FLAG_1
then lint will flag the first lines (assigning to 3, or any other constant than FLAG_0, FLAG_1 or FLAG_2), for both Java and Kotlin.
I'm going to close this as working as intended; feel free to file a new bug if there is some remaining scenario which is not working.
Description
Studio 173.4670218 (3.2 canary 8) + Kotlin plugin 1.2.40-eap-27.
Studio 173.4670197 (3.1) + Kotlin plugin 1.2.50-dev-155.
Make sure "Android | Lint | Correctness | Dangerous Flag Constant Declaration" inspection is enabled.
In Java source the problem is reported:
```
import android.support.annotation.IntDef;
public class DangerousFlagJava {
@IntDef(flag = true, value = { FLAG_0, FLAG_1, FLAG_2 })
@interface DangerousFace {}
public static final long FLAG_0 = 0L;
public static final long FLAG_1 = 1L;
public static final long FLAG_2 = 2L; // warning
}
```
In Kotlin is not:
```
import android.support.annotation.IntDef
object DangerousFlag {
@IntDef(flag = true, value = [FLAG_0, FLAG_1, FLAG_2])
annotation class DangerousFace
const val FLAG_0 = 0L
const val FLAG_1 = 1L
const val FLAG_2 = 2L // no warning
}
```
Old Kotlin issue is
Feel free to comment if something is necessary from Kotlin side.