[records] Compact constructor type parameters
Brian Goetz
brian.goetz at oracle.com
Sat Nov 9 11:47:49 UTC 2019
This is reasonable and probably easy to spec: when we define the canonical ctor, in addition to defining its is defined to have no type parameters. Since the compact ctor is shorthand for a full canonical ctor, no additional spec is needed for that.
Sent from my iPad
> On Nov 9, 2019, at 12:07 PM, Tagir Valeev <amaembo at gmail.com> wrote:
>
> Hello!
>
> Reading the latest JLS spec draft for records, chapter 8.10.5 [1] I
> see the following:
>
> A compact constructor declaration provides an alternative, succinct
> means to declare a canonical constructor for a record type.
> CompactConstructorDeclaration:{ Annotation } { ConstructorModifier } [
> TypeParameters ] SimpleTypeName ConstructorBody
>
> Is it really useful to allow type parameters specification for a
> compact constructor, given that we cannot alter the formal parameters
> list, thus we cannot use them there? Yes, we could use them to declare
> local variables but this is an implementation detail, thus it should
> not leak to the clients (especially given the fact that canonical
> constructors are always public). Should not we exclude type parameters
> from the compact constructor declaration?
>
> I think we can go even further and disable type parameters for
> explicit canonical constructor declaration (not in compact form) as
> well. WDYT?
>
> With best regards,
> Tagir Valeev.
>
> [1] http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jls.html#jls-8.10.5
More information about the amber-spec-experts
mailing list