RFR: 8259905: Compiler treats 'sealed' keyword as 'var' keyword

Jan Lahoda jlahoda at openjdk.java.net
Fri Jan 29 13:49:39 UTC 2021


On Thu, 28 Jan 2021 18:45:21 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> Hi,
> 
> Please review this fix which is basically fixing an oversaw issue affecting new restricted keywords: `sealed` and `permits`. The fix per se is in lines: 3341-3343, but then I made some additional changes to the position where previous errors were reported at method JavacParser::variableDeclaratorRest. That was done for consistency with the new code. I could have done the other way but then users would have two error notifications for some code, one for the use of the restricted type per se and another one for the use of the variable or field so like:
> 
> void m() {
>     sealed s1;
>     ^
>     compiler error here
>            ^
>                 and before you go, compiler error here too
> }
> I guess it make sense for the already existing code to be positioned on the use of the restricted type and not on the variable declared afterwards. Doing that adjustment has implied some changes to the golden file associated to test ParserTest. Also I added another case and did some additional editing to test SealedCompilationTests.
> 
> TIA

LGTM

-------------

Marked as reviewed by jlahoda (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2298


More information about the compiler-dev mailing list