<< §3.5.(g) Callout override | ↑ Table of Contents ↑ |
§3.5.(h) Inferred callout
If a statement or expression within the body of a bound role class
uses a simple name or a name qualified by this
which can not be resolved using normal rules,
the compiler may infer to use a callout to field instead,
given that a field of the required name can be found in the role's declared baseclass.
If a callout to field has explicitly been declared it is used for the otherwise unresolved name, if and only if:
- the callout declares a role method name the is constructed from the token "set" for a setter or "get" for a getter plus the field name with capital first letter,
- the base field referenced by the callout has exactly the required name, and
- the callout kind (set/get) matches the application of the unresolved name as either the left-hand side of an assignment (set) or as an expression (get).
If a matching callout to field is not found, the compiler generates one automatically,
which has private
visibility.
If a callout to field has been inferred it is an error to directly invoke the implicitly generated callout accessor that is formed according to the above rules.
Per default inferred callout bindings are disabled, i.e., a compiler
must report these as an error. However, a compiler should allow to
configure reporting to produce a warning only (which can be suppressed
using a @SuppressWarnings("inferredcallout")
annotation),
or to completely ignore the diagnostic. See also §3.1.(j).
<< §3.5.(g) Callout override | ↑ Table of Contents ↑ |