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 <[email protected]> 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