changeset 60097:e2821df4e6aa stats-before-this-super

Adding missing method.
author jlahoda
date Wed, 04 Mar 2020 12:25:00 +0100
parents 9ecc33cc755c
children 069db4509511
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Mar 04 12:01:01 2020 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Mar 04 12:25:00 2020 +0100
@@ -1207,6 +1207,26 @@
         }
     }
 
+        /** Check that given application node appears as first statement
+         *  in a constructor call.
+         *  @param tree          The application node
+         *  @param enclMethod    The enclosing method of the application.
+         *  @param error         Should an error be issued?
+         */
+        boolean checkFirstConstructorStat(JCMethodInvocation tree, JCMethodDecl enclMethod, boolean error) {
+            if (enclMethod != null && enclMethod.name == names.init) {
+                JCBlock body = enclMethod.body;
+                if (body.stats.head.hasTag(EXEC) &&
+                    ((JCExpressionStatement) body.stats.head).expr == tree)
+                    return true;
+            }
+            if (error) {
+                log.error(tree.pos(),
+                        Errors.CallMustBeFirstStmtInCtor(TreeInfo.name(tree.meth)));
+            }
+            return false;
+        }
+
     private int numberOfCallsToThisSuper(List<JCStatement> stats) {
         return (int)stats.stream().filter(s -> TreeInfo.isSelfCall(s)).count();
     }