changeset 58605:93920f18650a records

removing redundant code
author vromero
date Thu, 31 Oct 2019 23:59:56 -0400
parents 94af517243c6
children b92358773309
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java
diffstat 3 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Oct 31 21:06:09 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Oct 31 23:59:56 2019 -0400
@@ -1144,7 +1144,7 @@
                             log.error(tree, Errors.InvalidCanonicalConstructorInRecord(env.enclClass.sym, Fragments.CanonicalConstructorMustBePublic));
                         }
                         if (tree.sym.type.asMethodType().thrown != null && !tree.sym.type.asMethodType().thrown.isEmpty()) {
-                            log.error(tree.thrown.head,
+                            log.error(tree,
                                     Errors.InvalidCanonicalConstructorInRecord(env.enclClass.sym, Fragments.ThrowsClauseNotAllowedForCanonicalConstructor));
                         }
                     }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Oct 31 21:06:09 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Oct 31 23:59:56 2019 -0400
@@ -2196,7 +2196,7 @@
          * named a record component with a namesake, to the compiler will fail anyway with a more
          * meaningful message
          */
-        if (undef != null && !c.isRecord()) {
+        if (undef != null) {
             MethodSymbol undef1 =
                 new MethodSymbol(undef.flags(), undef.name,
                                  types.memberType(c.type, undef), undef.owner);
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Thu Oct 31 21:06:09 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Thu Oct 31 23:59:56 2019 -0400
@@ -1103,8 +1103,7 @@
          *  to the symbol table.
          */
         private void addRecordMembersIfNeeded(JCClassDecl tree, Env<AttrContext> env) {
-            if (lookupMethod(tree.sym, names.toString, List.nil()) == null &&
-                    !tree.sym.members().getSymbolsByName(names.toString).iterator().hasNext()) {
+            if (lookupMethod(tree.sym, names.toString, List.nil()) == null) {
                 // public String toString() { return ???; }
                 JCMethodDecl toString = make.
                     MethodDef(make.Modifiers(Flags.PUBLIC | Flags.RECORD | Flags.MANDATED),
@@ -1118,8 +1117,7 @@
                 memberEnter.memberEnter(toString, env);
             }
 
-            if (lookupMethod(tree.sym, names.hashCode, List.nil()) == null &&
-                    !tree.sym.members().getSymbolsByName(names.hashCode).iterator().hasNext()) {
+            if (lookupMethod(tree.sym, names.hashCode, List.nil()) == null) {
                 // public int hashCode() { return ???; }
                 JCMethodDecl hashCode = make.
                     MethodDef(make.Modifiers(Flags.PUBLIC | Flags.RECORD | Flags.FINAL | Flags.MANDATED),
@@ -1133,8 +1131,7 @@
                 memberEnter.memberEnter(hashCode, env);
             }
 
-            if (lookupMethod(tree.sym, names.equals, List.of(syms.objectType)) == null &&
-                    !tree.sym.members().getSymbolsByName(names.equals).iterator().hasNext()) {
+            if (lookupMethod(tree.sym, names.equals, List.of(syms.objectType)) == null) {
                 // public boolean equals(Object o) { return ???; }
                 JCMethodDecl equals = make.
                     MethodDef(make.Modifiers(Flags.PUBLIC | Flags.RECORD | Flags.FINAL | Flags.MANDATED),