8057650: uniform error diagnostics for inconsistent inherited method signatures
Summary: consolidate diagnostics for bad overrides
Reviewed-by: vromero
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Tue Dec 19 13:58:31 2017 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Wed Dec 20 15:33:31 2017 +0000
@@ -1976,8 +1976,8 @@
types.covariantReturnType(rt2, rt1, types.noWarnings)) ||
checkCommonOverriderIn(s1,s2,site);
if (!compat) {
- log.error(pos, Errors.TypesIncompatibleDiffRet(t1, t2, s2.name +
- "(" + types.memberType(t2, s2).getParameterTypes() + ")"));
+ log.error(pos, Errors.TypesIncompatible(t1, t2,
+ Fragments.IncompatibleDiffRet(s2.name, types.memberType(t2, s2).getParameterTypes())));
return s2;
}
} else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) &&
@@ -2563,20 +2563,22 @@
//strong semantics - issue an error if two sibling interfaces
//have two override-equivalent defaults - or if one is abstract
//and the other is default
- String errKey;
+ Fragment diagKey;
Symbol s1 = defaults.first();
Symbol s2;
if (defaults.size() > 1) {
- errKey = "types.incompatible.unrelated.defaults";
s2 = defaults.toList().tail.head;
+ diagKey = Fragments.IncompatibleUnrelatedDefaults(Kinds.kindName(site.tsym), site,
+ m.name, types.memberType(site, m).getParameterTypes(),
+ s1.location(), s2.location());
+
} else {
- errKey = "types.incompatible.abstract.default";
s2 = abstracts.first();
+ diagKey = Fragments.IncompatibleAbstractDefault(Kinds.kindName(site.tsym), site,
+ m.name, types.memberType(site, m).getParameterTypes(),
+ s1.location(), s2.location());
}
- log.error(pos, errKey,
- Kinds.kindName(site.tsym), site,
- m.name, types.memberType(site, m).getParameterTypes(),
- s1.location(), s2.location());
+ log.error(pos, Errors.TypesIncompatible(s1.location().type, s2.location().type, diagKey));
break;
}
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Dec 19 13:58:31 2017 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Dec 20 15:33:31 2017 +0000
@@ -1136,16 +1136,21 @@
compiler.err.type.var.more.than.once.in.result=\
type variable {0} occurs more than once in type of {1}; cannot be left uninstantiated
-# 0: type, 1: type, 2: string
-compiler.err.types.incompatible.diff.ret=\
- types {0} and {1} are incompatible; both define {2}, but with unrelated return types
+# 0: type, 1: type, 2: fragment
+compiler.err.types.incompatible=\
+ types {0} and {1} are incompatible;\n\
+ {2}
+
+# 0: name, 1: list of type
+compiler.misc.incompatible.diff.ret=\
+ both define {0}({1}), but with unrelated return types
# 0: kind name, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
-compiler.err.types.incompatible.unrelated.defaults=\
+compiler.misc.incompatible.unrelated.defaults=\
{0} {1} inherits unrelated defaults for {2}({3}) from types {4} and {5}
# 0: kind name, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
-compiler.err.types.incompatible.abstract.default=\
+compiler.misc.incompatible.abstract.default=\
{0} {1} inherits abstract and default for {2}({3}) from types {4} and {5}
# 0: name, 1: kind name, 2: symbol
--- a/test/langtools/tools/javac/BadCovar.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/BadCovar.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-BadCovar.java:22:10: compiler.err.types.incompatible.diff.ret: bad.covar.B, bad.covar.A, f()
+BadCovar.java:22:10: compiler.err.types.incompatible: bad.covar.B, bad.covar.A, (compiler.misc.incompatible.diff.ret: f, )
1 error
--- a/test/langtools/tools/javac/InconsistentInheritedSignature.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/InconsistentInheritedSignature.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-InconsistentInheritedSignature.java:17:1: compiler.err.types.incompatible.diff.ret: I2, I1, f()
+InconsistentInheritedSignature.java:17:1: compiler.err.types.incompatible: I2, I1, (compiler.misc.incompatible.diff.ret: f, )
1 error
--- a/test/langtools/tools/javac/OverrideChecks/InconsistentReturn.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/OverrideChecks/InconsistentReturn.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-InconsistentReturn.java:17:1: compiler.err.types.incompatible.diff.ret: I2, I1, f()
+InconsistentReturn.java:17:1: compiler.err.types.incompatible: I2, I1, (compiler.misc.incompatible.diff.ret: f, )
1 error
--- a/test/langtools/tools/javac/defaultMethods/Neg01.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/defaultMethods/Neg01.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-Neg01.java:14:12: compiler.err.types.incompatible.unrelated.defaults: kindname.class, Neg01.AB, m, , Neg01.IA, Neg01.IB
+Neg01.java:14:12: compiler.err.types.incompatible: Neg01.IA, Neg01.IB, (compiler.misc.incompatible.unrelated.defaults: kindname.class, Neg01.AB, m, , Neg01.IA, Neg01.IB)
1 error
--- a/test/langtools/tools/javac/defaultMethods/Neg02.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/defaultMethods/Neg02.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-Neg02.java:16:13: compiler.err.types.incompatible.unrelated.defaults: kindname.class, Neg02.X, m, , Neg02.A, Neg02.B
+Neg02.java:16:13: compiler.err.types.incompatible: Neg02.A, Neg02.B, (compiler.misc.incompatible.unrelated.defaults: kindname.class, Neg02.X, m, , Neg02.A, Neg02.B)
1 error
--- a/test/langtools/tools/javac/defaultMethods/Neg14.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/defaultMethods/Neg14.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-Neg14.java:10:14: compiler.err.types.incompatible.abstract.default: kindname.class, Neg14.AB, m, , Neg14.IB, Neg14.IA
+Neg14.java:10:14: compiler.err.types.incompatible: Neg14.IB, Neg14.IA, (compiler.misc.incompatible.abstract.default: kindname.class, Neg14.AB, m, , Neg14.IB, Neg14.IA)
1 error
--- a/test/langtools/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java Wed Dec 20 15:33:31 2017 +0000
@@ -21,7 +21,8 @@
* questions.
*/
-// key: compiler.err.types.incompatible.diff.ret
+// key: compiler.err.types.incompatible
+// key: compiler.misc.incompatible.diff.ret
// key: compiler.err.prob.found.req
// key: compiler.misc.incompatible.descs.in.functional.intf
// key: compiler.misc.descriptor
--- a/test/langtools/tools/javac/diags/examples/TypesIncompatible.java Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/diags/examples/TypesIncompatible.java Wed Dec 20 15:33:31 2017 +0000
@@ -21,7 +21,8 @@
* questions.
*/
-// key: compiler.err.types.incompatible.diff.ret
+// key: compiler.err.types.incompatible
+// key: compiler.misc.incompatible.diff.ret
interface A {
int m();
--- a/test/langtools/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java Wed Dec 20 15:33:31 2017 +0000
@@ -21,7 +21,8 @@
* questions.
*/
-// key: compiler.err.types.incompatible.abstract.default
+// key: compiler.err.types.incompatible
+// key: compiler.misc.incompatible.abstract.default
class TypesIncompatibleAbstractDefault {
interface A {
--- a/test/langtools/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java Wed Dec 20 15:33:31 2017 +0000
@@ -21,7 +21,8 @@
* questions.
*/
-// key: compiler.err.types.incompatible.unrelated.defaults
+// key: compiler.err.types.incompatible
+// key: compiler.misc.incompatible.unrelated.defaults
class TypesIncompatibleUnrelatedDefaults {
interface A {
--- a/test/langtools/tools/javac/generics/6294779/T6294779c.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/6294779/T6294779c.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T6294779c.java:29:5: compiler.err.types.incompatible.diff.ret: T6294779c.I2, T6294779c.I1, get()
+T6294779c.java:29:5: compiler.err.types.incompatible: T6294779c.I2, T6294779c.I1, (compiler.misc.incompatible.diff.ret: get, )
1 error
--- a/test/langtools/tools/javac/generics/abstract/T4717181c.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/abstract/T4717181c.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T4717181c.java:15:21: compiler.err.types.incompatible.diff.ret: T4717181c.A<java.lang.Integer>, T4717181c.A<java.lang.Integer>, f(java.lang.Integer)
+T4717181c.java:15:21: compiler.err.types.incompatible: T4717181c.A<java.lang.Integer>, T4717181c.A<java.lang.Integer>, (compiler.misc.incompatible.diff.ret: f, java.lang.Integer)
1 error
--- a/test/langtools/tools/javac/generics/rawOverride/7157798/Test3.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/rawOverride/7157798/Test3.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,6 +1,6 @@
-Test3.java:14:1: compiler.err.types.incompatible.diff.ret: B, A, m()
-Test3.java:19:1: compiler.err.types.incompatible.diff.ret: D, C, m()
-Test3.java:27:1: compiler.err.types.incompatible.diff.ret: E<T>, B, m()
-Test3.java:33:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m()
-Test3.java:37:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m()
+Test3.java:14:1: compiler.err.types.incompatible: B, A, (compiler.misc.incompatible.diff.ret: m, )
+Test3.java:19:1: compiler.err.types.incompatible: D, C, (compiler.misc.incompatible.diff.ret: m, )
+Test3.java:27:1: compiler.err.types.incompatible: E<T>, B, (compiler.misc.incompatible.diff.ret: m, )
+Test3.java:33:1: compiler.err.types.incompatible: F<V>, E<U>, (compiler.misc.incompatible.diff.ret: m, )
+Test3.java:37:1: compiler.err.types.incompatible: F<V>, E<U>, (compiler.misc.incompatible.diff.ret: m, )
5 errors
--- a/test/langtools/tools/javac/generics/typevars/4856983/T4856983a.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/typevars/4856983/T4856983a.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T4856983a.java:13:6: compiler.err.types.incompatible.diff.ret: I2, I1, m()
+T4856983a.java:13:6: compiler.err.types.incompatible: I2, I1, (compiler.misc.incompatible.diff.ret: m, )
1 error
--- a/test/langtools/tools/javac/generics/typevars/4856983/T4856983b.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/typevars/4856983/T4856983b.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T4856983b.java:12:24: compiler.err.types.incompatible.diff.ret: I2, I1, m()
+T4856983b.java:12:24: compiler.err.types.incompatible: I2, I1, (compiler.misc.incompatible.diff.ret: m, )
1 error
--- a/test/langtools/tools/javac/generics/typevars/6199146/T6199146.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/typevars/6199146/T6199146.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T6199146.java:9:25: compiler.err.types.incompatible.diff.ret: T6199146.I2, T6199146.I1, getFoo()
+T6199146.java:9:25: compiler.err.types.incompatible: T6199146.I2, T6199146.I1, (compiler.misc.incompatible.diff.ret: getFoo, )
1 error
--- a/test/langtools/tools/javac/generics/wildcards/7034495/T7034495.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/generics/wildcards/7034495/T7034495.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B<compiler.misc.type.captureof: 1, ?>, T7034495.A<compiler.misc.type.captureof: 2, ?>, foo()
+T7034495.java:40:17: compiler.err.types.incompatible: T7034495.B<compiler.misc.type.captureof: 1, ?>, T7034495.A<compiler.misc.type.captureof: 2, ?>, (compiler.misc.incompatible.diff.ret: foo, )
1 error
--- a/test/langtools/tools/javac/lambda/BadConv04.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/lambda/BadConv04.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,3 +1,3 @@
-BadConv04.java:19:5: compiler.err.types.incompatible.diff.ret: BadConv04.I2, BadConv04.I1, m()
+BadConv04.java:19:5: compiler.err.types.incompatible: BadConv04.I2, BadConv04.I1, (compiler.misc.incompatible.diff.ret: m, )
BadConv04.java:21:13: compiler.err.prob.found.req: (compiler.misc.incompatible.descs.in.functional.intf: kindname.interface, BadConv04.SAM,{(compiler.misc.descriptor: m, , long, ),(compiler.misc.descriptor: m, , int, )})
2 errors
--- a/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java Wed Dec 20 15:33:31 2017 +0000
@@ -1001,18 +1001,18 @@
public void testA5() throws IOException, ReflectiveOperationException {
compileSpec("C(A(Id0),Jd0)",
- "compiler.err.types.incompatible.unrelated.defaults");
+ "compiler.err.types.incompatible");
}
public void testA6() throws IOException, ReflectiveOperationException {
compileSpec("C(A(Ia0,Jd0))",
"compiler.err.does.not.override.abstract",
- "compiler.err.types.incompatible.abstract.default");
+ "compiler.err.types.incompatible");
}
public void testA7() throws IOException, ReflectiveOperationException {
compileSpec("C(A(Id0,Jd0))",
- "compiler.err.types.incompatible.unrelated.defaults");
+ "compiler.err.types.incompatible");
}
public void testA8() throws IOException, ReflectiveOperationException {
--- a/test/langtools/tools/javac/lambda/funcInterfaces/NonSAM2.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/lambda/funcInterfaces/NonSAM2.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,4 +1,4 @@
-NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String)
+NonSAM2.java:13:1: compiler.err.types.incompatible: Bar1, Foo1, (compiler.misc.incompatible.diff.ret: getAge, java.lang.String)
NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest, java.util.List<?>, C, getOldest, java.util.List<java.lang.Number>, A
NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest, java.util.List<java.lang.Integer>, D, getOldest, java.util.List<java.lang.Number>, A
NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m, T2, Bar2, m, T1, Foo2
--- a/test/langtools/tools/javac/miranda/4711056/T1.out Tue Dec 19 13:58:31 2017 -0800
+++ b/test/langtools/tools/javac/miranda/4711056/T1.out Wed Dec 20 15:33:31 2017 +0000
@@ -1,2 +1,2 @@
-T4.java:3:10: compiler.err.types.incompatible.diff.ret: iclss01004_2, iclss01004_1, foo(int)
+T4.java:3:10: compiler.err.types.incompatible: iclss01004_2, iclss01004_1, (compiler.misc.incompatible.diff.ret: foo, int)
1 error