< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

Print this page

        

@@ -1014,10 +1014,19 @@
                 log.error(tree.params.nonEmpty() ?
                         tree.params.head.pos() :
                         tree.recvparam.pos(),
                         Errors.IntfAnnotationMembersCantHaveParams);
 
+            if ((owner.flags() & RECORD) != 0) {
+                List<VarSymbol> recordFieldSymbols = types.recordVars(env.enclClass.type);
+                List<Name> forbiddenMethodNames = recordFieldSymbols.map(vd -> vd.name);
+                forbiddenMethodNames = forbiddenMethodNames.prependList(List.of(names.hashCode, names.equals));
+                if (forbiddenMethodNames.contains(m.name)) {
+                    log.error(tree, Errors.CantProvideExplicitVersion(m.name));
+                }
+            }
+
             // Attribute all value parameters.
             for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
                 attribStat(l.head, localEnv);
             }
 

@@ -1085,16 +1094,15 @@
                 // super(...) or this(...) is given
                 // or we are compiling class java.lang.Object.
                 if (tree.name == names.init && owner.type != syms.objectType) {
                     JCBlock body = tree.body;
                     if (body.stats.isEmpty() ||
-                            !TreeInfo.isSelfCall(body.stats.head)) {
-                        body.stats = body.stats.
-                                prepend(typeEnter.SuperCall(make.at(body.pos),
-                                        List.nil(),
-                                        List.nil(),
-                                        false));
+                            TreeInfo.getConstructorInvocationName(body.stats, names,
+                                    (env.enclClass.sym.flags() & RECORD) != 0) == names.empty) {
+                        JCStatement supCall = make.at(body.pos).Exec(make.Apply(List.nil(),
+                                make.Ident(names._super), make.Idents(List.nil())));
+                        body.stats = body.stats.prepend(supCall);
                     } else if ((env.enclClass.sym.flags() & ENUM) != 0 &&
                             (tree.mods.flags & GENERATEDCONSTR) == 0 &&
                             TreeInfo.isSuperCall(body.stats.head)) {
                         // enum constructors are not allowed to call super
                         // directly, so make sure there aren't any super calls

@@ -3134,11 +3142,10 @@
                 }
                 lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared(newScopeOwner)));
             } else {
                 lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup()));
             }
-            lambdaEnv.info.breakResult = null;
             return lambdaEnv;
         }
 
     @Override
     public void visitReference(final JCMemberReference that) {
< prev index next >