Record component type can be an inner class of a record

forax at univ-mlv.fr forax at univ-mlv.fr
Sun Apr 19 16:40:16 UTC 2020


Hi Dan,

----- Mail original -----
> De: "daniel smith" <daniel.smith at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "Gavin Bierman" <gavin.bierman at oracle.com>, "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Lundi 13 Avril 2020 21:13:51
> Objet: Re: Record component type can be an inner class of a record

>> On Apr 13, 2020, at 11:08 AM, forax at univ-mlv.fr wrote:
>> 
>> I believe you're right, the following code should not compile, apart if you want
>> to write puzzler for a living :)
>> 
>> class A { int y; }
>>   
>> record B(A a) implements I {
>>   public static void main(String[] args) {
>>     System.out.println(new B(null).a().x);
>>   }
>> }
>>  
>> interface I {
>>   class A { int x; }
>> }
> 
> You're proposing a novel error check, which I'm not sure is a good idea.

I think you mis-read it.
It's an example that shows that depending if the record component type is resolve as part of outside of the record or inside the record, not the same A is picked.
The A at top level declare a field "y" while the A inside I declare a field "x", that why it doesn't compile.
So it's not a new error check.

regards,
Rémi


More information about the amber-spec-experts mailing list