-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
The documentation for Modifiable.hasModifier(string) says:
For most purposes, the more specialized predicates
isAbstract,isPublic, etc. should be used, which also take implicit modifiers into account.
This suggests that it should only hold if an explicit modifier is used. However, this does not seem to be the case.
This makes it difficult to write any queries taking explicit modifier usage into account (e.g. checking for redundant modifiers), and also renders some special casing code in the CodeQL classes pointless.
The current behavior is therefore probably incorrect, only the respective predicates, such as isFinal() or isStatic(), which explicitly mention that they also hold for implicit modifiers should hold. Predicates reporting explicit modifiers such as hasModifier, and probably also getAModifier and hasNoModifier, should not hold. Their documentation should also more clearly mention that they only are supposed to only match explicit modifiers.
Affected cases
(List is likely incomplete)
- Records: Are always reported as
finaland, for nested records,static
Query Console link - Enums are always reported as
finaland, for nested enums,static - Nested interfaces are always reported as
static - Interface methods are always reported as
public(unless explicitlyprivate) andabstract(unlessdefaultorstatic) - Interface fields are always reported as
static