Fixed
Status Update
Comments
uc...@google.com <uc...@google.com>
es...@google.com <es...@google.com>
tn...@google.com <tn...@google.com> #2
Thanks for the clear repro steps! Fix pending in Change-Id: I620c9804e5038b20e6b071fb34be17b6e6803939.
Description
Build #AI-183.4588.61.34.5202479, built on December 27, 2018
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.18.10-1rodete2-amd64
Android Gradle Plugin: 3.4.0-alpha10
When using Locale.getDefault() within a method declared on an enum value, the use is flagged by Lint [ConstantLocale] as being assigned to a static final constant. This is reproducible in both Java and Kotlin code. The simplest reproduction case is just:
public enum JavaEnum {
VALUE {
public Locale getDefaultLocale() {
return Locale.getDefault();
}
}
}
or
enum class KotlinEnum {
VALUE {
fun getDefaultLocale() = Locale.getDefault()
}
}
Since these methods are evaluated when called, the correct value will be resolved at the time, so I believe this is a false positive.