invocation type of method reference declaration
daniel.smith at oracle.com
Thu Feb 13 16:31:27 PST 2014
On Feb 12, 2014, at 6:00 PM, Rafkind, Jon <jon.rafkind at hp.com> wrote:
> What is the invocation type of the compile-time chosen method
> declaration of a method reference?
> In section 15.3.2:
> The return type of the function type is R; the result of applying
> capture conversion (5.1.10) to the return type of the invocation type
> (188.8.131.52) of the chosen declaration is R', where R is the target type
> that may be used to infer R'; neither R nor R' is void; and R' is
> compatible with R in an assignment context.
> Also in section 184.108.40.206:
> Otherwise, let R be the return type of the function type, and let R' be
> the result of applying capture conversion (5.1.10) to the return type of
> the invocation type (220.127.116.11) of the chosen declaration. If R' is
> void, the constraint reduces to false; otherwise, the constraint reduces
> to ⟨R' → R⟩.
> A method reference is not the same as a method invocation so 18.104.22.168
> don't seem to apply. Are the parameters of the function type supposed to
> act as the types of the argument expressions to the compile-time
There is admittedly a degree of informality here (consistent with the style of the rest of JLS), but I'm not seeing any particular points that need clarification. (Feel free to point them out if you think I'm missing something.)
The following terms are a bit fuzzy, but have only one reasonable interpretation:
- The "explicit type arguments" of the "method invocation". Of course this refers to the type arguments of the method reference, a pattern already established in 15.13.1.
- Whether "unchecked conversion was necessary for the method to be applicable". The applicability test is as described in 22.214.171.124-126.96.36.199, as applied from 15.13.1.
- The "type that was searched" is defined in 15.13.1.
- During inference, we need to know whether "the invocation is a poly expression" (18.5.2). This is probably the least well-defined. The rules for whether a method invocation is a poly expression are in 15.12; analogous rules can be applied to the method reference in order to decide whether that particular branch in 18.5.2 should be pursued or not (specifically: the method reference does not have type arguments, the compile-time declaration is generic, and the return type of the compile-time declaration mentions one of its type parameters).
I'll create a bug to clarify that last point in the future.
More information about the lambda-spec-observers