RFR JDK14-8236597: issues inferring type annotations on records

Vicente Romero vicente.romero at oracle.com
Fri Jan 10 00:34:02 UTC 2020


Hi,

Please review this patch [1] to fix a couple of issues regarding 
inference of type annotations on records [2]. There where two cases 
where type annotations were reported as missing. For compact records 
whose arguments are not inheriting the type annotations from the 
corresponding record component and for accessors for which the 
annotation was present but just as a declaration annotation applied to 
the accessor. Not as a type annotation applied to the return type which 
was the expected outcome.

In the case of the compact constructor, the solution was just to copy 
the annotations to the parameters which were missing. In the case of the 
accessor the solution was a bit more complicated. Accessors are created 
but not added to the list definitions belonging to the record tree. This 
is done to make them invisible to type attribution as they are not fully 
fledge methods, but as a side effect they are also invisible to the type 
annotations machinery. For this reason type annotations were not 
recognized as such. The solution here has been to make the type 
annotations machinery to visit accessors for records and set the type 
annotations correctly. In order to do that the accessor method created 
at TypeEnter is stored at the record component and visited at the same 
time type annotations are being classified for the rest of the code.

Thanks,
Vicente

[1] http://cr.openjdk.java.net/~vromero/8236597/webrev.00/
[2] https://bugs.openjdk.java.net/browse/JDK-8236597


More information about the compiler-dev mailing list