Record component type can be an inner class of a record
Gavin Bierman
gavin.bierman at oracle.com
Mon Apr 13 16:37:14 UTC 2020
Thanks for pointing this out Remi. We definitely need to tweak the draft spec to deal with this scoping question.
However, I am of the opinion that this example should not be allowed. I would expect the scope of things defined in a record body to be the record body. I don’t think the record header should be considered part of the body. Analogously:
class Foo<T extends Bar> {
class Bar { … }
…
}
This doesn’t work as the scope of the Bar declaration is the class body.
What do you think?
Gavin
> On 24 Mar 2020, at 20:57, Remi Forax <forax at univ-mlv.fr> wrote:
>
> Hi all,
> a record component can use as type a type declared inside the record itself,
> in term of scoping it's like if the record component is part of the internal scope of the record.
>
> record Foo(Bar bar) {
> class Bar {
>
> }
> }
>
> I think it's the right behaviour but i was not able to find any reference to that in the spec.
>
> regards,
> Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200413/3114d785/attachment.htm>
More information about the amber-spec-experts
mailing list