diff options
author | Tor Norbye <tnorbye@google.com> | 2012-09-04 07:08:02 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-09-04 10:55:58 -0700 |
commit | 243dbe730c5be7f487d4c8ef871bf204d02333ff (patch) | |
tree | db3b8560f636f56416081c24451998001ac514b9 /ide_common | |
parent | 5e6a790489d434ebe412e7a479053c923ebe9485 (diff) | |
download | sdk-243dbe730c5be7f487d4c8ef871bf204d02333ff.zip sdk-243dbe730c5be7f487d4c8ef871bf204d02333ff.tar.gz sdk-243dbe730c5be7f487d4c8ef871bf204d02333ff.tar.bz2 |
36951: Lint API Level Warnings for Enums are Confusing
When using switch statements on enums, the compiler will generate
extra code to make the switch invocation efficient. For example, it
generates a method which looks up all the values in the enum, calls
ordinal() on each, and then creates an array which has all the enum
values indexed by ordinal.
The problem is that this helper code will end up referencing fields
which may have a higher API requirement than is currently being used,
and Lint would flag these as illegal API references. That's not
correct in this case; as long as the corresponding jump table does not
actually use these references, there's no problem.
This changeset makes lint aware of this pattern, and when it
encounters an invalid field reference inside one of these synthetic
switch constant lookup methods, it will search for the corresponding
table lookup, check whether the actual key is used, and only in that
case complain.
It also makes error messages associated with enums in general a bit
better, when the whole enum class itself requires a higher API. (This
would generate a message related to invocation of ordinal() which
might not be obvious to everybody.) Finally, it cleans up class name
formatting such that we never reference inner classes using "$" in
error messages.
Change-Id: I28a14084c160866e69f63f62b5bc8f21ee50215c
Diffstat (limited to 'ide_common')
0 files changed, 0 insertions, 0 deletions