Concise method body + type inference ?

forax at univ-mlv.fr forax at univ-mlv.fr
Wed Oct 3 22:32:08 UTC 2018



----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Jeudi 4 Octobre 2018 00:17:47
> Objet: Re: Concise method body + type inference ?

>> I wonder if the concise method body proposal should not be extended to add
>> parameters types/return type inference in case of overriding methods.
> 
> In LVTI, we drew a bright line between inference in implementations and
> inference in declarations, for a good reason.  Clever observers
> commented that "but you could safely use `var` to infer the return type
> of a private method, without inviting API instability", but we declined
> on the basis that the incremental complexity of the rules (having a
> coupling between accessibility and inference) was not justified by the
> incremental expressiveness.  The current rules restrict inference to
> local variables, which is nice and clean and orthogonal.  I would make
> the same argument for not introducing a similar coupling here.

Here the coupling is not between accessibility and inference, it's between overridden methods and inference, this coupling already exists, we have even introduced the annotation @Override in Java 5 and 6 to make the coupling stronger, to be sure that people see that an overridden method and its implementation are strongly linked.

Rémi


More information about the amber-spec-experts mailing list