ArgumentType which can then be used for performing fast overload
checks without requiring multiple attribution passes over the same code.
The attribution strategy for a given method/constructor argument A is as follows:
- if A is potentially a poly expression (i.e. diamond instance creation expression), a speculative
pass over A is performed; the results of such speculative attribution are then saved in a special
type, so that enclosing overload resolution can be carried by simply checking compatibility against the
type determined during this speculative pass.
- if A is a standalone expression, regular attribution takes place.
To minimize the speculative work, a cache is used, so that already computed argument types
associated with a given unique source location are never recomputed multiple times.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv abstract class | ArgumentAttr.
An argument type is similar to a plain deferred type; the most important difference is that the completion logic associated with argument types allows speculative attribution to be skipped during overload resolution - that is, an argument type always has enough information to perform an overload check without the need of calling back to Attr. |
| pack-priv class | ArgumentAttr.
Argument type for conditionals. |
| pack-priv class | ArgumentAttr.
Argument type for explicit lambdas. |
| pack-priv class | ArgumentAttr.
Local cache context; this class keeps track of the previous cache and reverts to it
when the |
| pack-priv class | ArgumentAttr.
Argument type for parenthesized expression. |
| pack-priv class | ArgumentAttr.
Argument type for constructors. |
| pack-priv abstract class | ArgumentAttr.
Argument type for methods/constructors. |
| pack-priv class | ArgumentAttr.
Argument type for methods. |
| pack-priv class | ArgumentAttr.
Argument type for switch expressions. |
| pack-priv class | ArgumentAttr.
An instance of this class represents a unique position in a compilation unit. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Map | argumentTypeCache
Cache for argument types; behavior is influenced by the currently selected cache policy. |
| private final Attr | |
| private final DeferredAttr | |
| private final JCDiagnostic. | |
| private Env | env
Attribution environment to be used. |
| private final Log | |
| protected static final Context. | |
| pack-priv Type | result
Result of method attribution. |
| private final Symtab |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Type | attribArg(JCTree tree, Env<AttrContext> env)
Main entry point for attributing an argument with given tree and attribution environment. |
| pack-priv Type | checkSpeculative(JCTree expr, Attr.
Checks a type in the speculative tree against a given result; the type can be either a plain type or an argument type, in which case a more complex check is required. |
| pack-priv Type | checkSpeculative(JCDiagnostic.
Checks a type in the speculative tree against a given result; the type can be either a plain type or an argument type, in which case a more complex check is required. |
| public static ArgumentAttr | |
| pack-priv <T extends JCTree. | processArg(T that, Function<T, Z> argumentTypeFactory)
Process a method argument; this method takes care of performing a speculative pass over the argument tree and calling a well-defined entry point to build the argument type associated with such tree. |
| pack-priv <T extends JCTree. | processArg(T that, Supplier<Z> argumentTypeFactory)
Process a method argument; this method allows the caller to specify a custom speculative attribution logic (this is used e.g. for lambdas). |
| pack-priv void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| pack-priv ArgumentAttr. | withLocalCacheContext()
Returns a local caching context in which argument types can safely be cached without the risk of polluting enclosing contexts. |