javac compiler message when class extends record
Tagir Valeev
amaembo at gmail.com
Thu Dec 19 04:48:46 UTC 2019
Btw note that "record Test() extends Record {}" is not parseable at
all. The compiler message here is the following:
Test.java:1: error: '{' expected
record Test() extends Record {}
^
So "records cannot directly extend Record" is never displayed for the records.
With best regards,
Tagir Valeev.
On Thu, Dec 19, 2019 at 11:45 AM Tagir Valeev <amaembo at gmail.com> wrote:
>
> Hello!
>
> Consider the following code:
>
> class Test extends Record {}
>
> When I compile it (build 14-ea+27-1339) I see the following message:
>
> Test.java:1: error: records cannot directly extend Record
> class Test extends Record {}
> ^
> Note: Test.java uses preview language features.
> Note: Recompile with -Xlint:preview for details.
> 1 error
>
> I think it's somewhat confusing as it's not a record at all. For
> comparison, here's what we have if we change Record to Enum:
>
> Test.java:1: error: classes cannot directly extend java.lang.Enum
> class Test extends Enum {}
> ^
>
> I expect a similar message like "classes cannot directly extend
> java.lang.Record" in the first case. WDYT?
>
> With best regards,
> Tagir Valeev.
More information about the amber-dev
mailing list