RFR: JDK-8243074: Misplaced and/or duplicate super or this constructor invocation not attributed
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Apr 17 17:19:35 UTC 2020
Looks good!
Thanks
Maurizio
On 17/04/2020 16:27, Jan Lahoda wrote:
> Hi,
>
> Consider code like:
> ---
> class Constructors extends BaseWithConstructor {
> Constructors(String name) {
> System.err.println();
> this(name.length());
> super(name.length());
> this(name.length());
> }
> Constructors(int i) {super(i);}
> }
> class BaseWithConstructor {
> BaseWithConstructor(int len) {}
> }
> ---
>
> Attr.visitApply will not attribute the this/super constructor
> invocations inside Constructors(String name), as it only attributes
> the first this/super constructor invocation (if any). As a result
> Trees.getElement (or Trees.getTypeMirror) will not return good results
> on AST node from inside these this/super constructor invocations.
>
> The proposed solution is to attribute all super/this constructor
> invocations in Attr.visitApply. If the super/this constructor is
> misplaced, or duplicated, it will still get flagged as an error, but
> the AST will be enhanced with Symbols and Types.
>
> Webrev:
> http://cr.openjdk.java.net/~jlahoda/8243074/webrev.00/
>
> JBS: https://bugs.openjdk.java.net/browse/JDK-8243074
>
> How does this look?
>
> Thanks,
> Jan
More information about the compiler-dev
mailing list