1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jan 28 00:09:38 2011 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jan 28 12:01:07 2011 +0000 1.3 @@ -2121,7 +2121,7 @@ 1.4 1.5 public boolean accepts(Symbol s) { 1.6 return s.kind == MTH && 1.7 - (s.flags() & SYNTHETIC) == 0 && 1.8 + (s.flags() & (SYNTHETIC | CLASH)) == 0 && 1.9 s.isInheritedIn(site.tsym, types) && 1.10 !s.isConstructor(); 1.11 } 1.12 @@ -2581,28 +2581,42 @@ 1.13 if (sym.owner.name == names.any) return false; 1.14 for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { 1.15 if (sym != e.sym && 1.16 + (e.sym.flags() & CLASH) == 0 && 1.17 sym.kind == e.sym.kind && 1.18 sym.name != names.error && 1.19 (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { 1.20 - if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) 1.21 + if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { 1.22 varargsDuplicateError(pos, sym, e.sym); 1.23 - else if (sym.kind == MTH && !types.overrideEquivalent(sym.type, e.sym.type)) 1.24 + return true; 1.25 + } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) { 1.26 duplicateErasureError(pos, sym, e.sym); 1.27 - else 1.28 + sym.flags_field |= CLASH; 1.29 + return true; 1.30 + } else { 1.31 duplicateError(pos, e.sym); 1.32 - return false; 1.33 + return false; 1.34 + } 1.35 } 1.36 } 1.37 return true; 1.38 } 1.39 //where 1.40 - /** Report duplicate declaration error. 1.41 - */ 1.42 - void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { 1.43 - if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { 1.44 - log.error(pos, "name.clash.same.erasure", sym1, sym2); 1.45 + boolean hasSameSignature(Type mt1, Type mt2) { 1.46 + if (mt1.tag == FORALL && mt2.tag == FORALL) { 1.47 + ForAll fa1 = (ForAll)mt1; 1.48 + ForAll fa2 = (ForAll)mt2; 1.49 + mt2 = types.subst(fa2, fa2.tvars, fa1.tvars); 1.50 + } 1.51 + return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType()); 1.52 } 1.53 - } 1.54 + 1.55 + /** Report duplicate declaration error. 1.56 + */ 1.57 + void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { 1.58 + if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { 1.59 + log.error(pos, "name.clash.same.erasure", sym1, sym2); 1.60 + } 1.61 + } 1.62 1.63 /** Check that single-type import is not already imported or top-level defined, 1.64 * but make an exception for two single-type imports which denote the same type.