--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Nov 12 06:13:14 2015 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Nov 12 08:39:23 2015 +0530
@@ -1730,11 +1730,18 @@
boolean resultTypesOK =
types.returnTypeSubstitutable(mt, ot, otres, overrideWarner);
if (!resultTypesOK) {
- log.error(TreeInfo.diagnosticPositionFor(m, tree),
- "override.incompatible.ret",
- cannotOverride(m, other),
- mtres, otres);
- m.flags_field |= BAD_OVERRIDE;
+ if ((m.flags() & STATIC) != 0 && (other.flags() & STATIC) != 0) {
+ log.error(TreeInfo.diagnosticPositionFor(m, tree),
+ Errors.OverrideIncompatibleRet(Fragments.CantHide(m, m.location(), other,
+ other.location()), mtres, otres));
+ m.flags_field |= BAD_OVERRIDE;
+ } else {
+ log.error(TreeInfo.diagnosticPositionFor(m, tree),
+ "override.incompatible.ret",
+ cannotOverride(m, other),
+ mtres, otres);
+ m.flags_field |= BAD_OVERRIDE;
+ }
return;
} else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree),