changeset 56918:e7455c3923d9 records-and-sealed

improving error message in records
author vromero
date Mon, 08 Jul 2019 19:09:33 -0400
parents b9beeba97204
children 180ed622d987
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties test/langtools/tools/javac/records/mandated_members/accessors/BadAccessorsTest.out
diffstat 3 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Mon Jul 08 18:54:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Mon Jul 08 19:09:33 2019 -0400
@@ -1143,7 +1143,7 @@
                         log.error(TreeInfo.declarationFor(implSym, env.enclClass), Errors.MethodMustBePublic(implSym.name));
                     }
                     if (!types.isSameType(implSym.type.getReturnType(), tree.sym.type)) {
-                        log.error(TreeInfo.declarationFor(implSym, env.enclClass), Errors.AccessorReturnTypeDoesntMatch);
+                        log.error(TreeInfo.declarationFor(implSym, env.enclClass), Errors.AccessorReturnTypeDoesntMatch(tree.sym.type, implSym.type.getReturnType()));
                     }
                 }
             }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jul 08 18:54:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jul 08 19:09:33 2019 -0400
@@ -3463,8 +3463,11 @@
 compiler.err.constructor.with.same.erasure.as.canonical=\
     constructor with same erasure as canonical constructor
 
+# 0: type, 1: type
 compiler.err.accessor.return.type.doesnt.match=\
-    type returned by the accessor is not the same as the type of the corresponding record component
+    type returned by the accessor is not the same as the type of the corresponding record component\n\
+    required: {0}\n\
+    found:    {1}\n\
 
 ############################################
 # messages previouly at javac.properties
--- a/test/langtools/tools/javac/records/mandated_members/accessors/BadAccessorsTest.out	Mon Jul 08 18:54:23 2019 -0400
+++ b/test/langtools/tools/javac/records/mandated_members/accessors/BadAccessorsTest.out	Mon Jul 08 19:09:33 2019 -0400
@@ -1,5 +1,5 @@
 BadAccessorsTest.java:12:13: compiler.err.method.must.be.public: i
 BadAccessorsTest.java:13:21: compiler.err.method.must.be.public: j
 BadAccessorsTest.java:14:23: compiler.err.method.must.be.public: k
-BadAccessorsTest.java:16:21: compiler.err.accessor.return.type.doesnt.match
+BadAccessorsTest.java:16:21: compiler.err.accessor.return.type.doesnt.match: java.util.List<java.lang.String>, java.util.List
 4 errors