Loosening requirements for super() invocation

Brian Goetz brian.goetz at oracle.com
Wed Jan 25 21:23:56 UTC 2023


> I'm still not understanding (sorry).
>
> The new rule for implicit supers would be syntactic as well.
>
> The rule is this: Add an implicit super() if there are NO occurrences 
> of any this() or a super() anywhere in the constructor.

So, let's look at the grammar.  Where does the production that matches 
`super(e)` come from?  Its from ConstructorBody:

     ConstructorBody:
     { [ExplicitConstructorInvocation] [BlockStatements] }

If you pull on the string for BlockStatements, you'll see a whole nest 
of statement forms, *none of which match this(e) or super(e)*. So to 
allow one of these statements inside a block, you have to refactor all 
the statement productions in the language.  Then you have to go through 
the entire spec and prohibit these in the places where they can't be 
used (such as lambdas.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230125/9e20febc/attachment.htm>


More information about the amber-dev mailing list