1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Aug 11 01:12:40 2009 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Aug 11 01:13:14 2009 +0100 1.3 @@ -65,6 +65,7 @@ 1.4 private final Types types; 1.5 private final JCDiagnostic.Factory diags; 1.6 private final boolean skipAnnotations; 1.7 + private boolean warnOnSyntheticConflicts; 1.8 private final TreeInfo treeinfo; 1.9 1.10 // The set of lint options currently in effect. It is initialized 1.11 @@ -99,6 +100,7 @@ 1.12 allowAnnotations = source.allowAnnotations(); 1.13 complexInference = options.get("-complexinference") != null; 1.14 skipAnnotations = options.get("skipAnnotations") != null; 1.15 + warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null; 1.16 1.17 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); 1.18 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); 1.19 @@ -1709,6 +1711,35 @@ 1.20 checkCompatibleConcretes(pos, c); 1.21 } 1.22 1.23 + void checkConflicts(DiagnosticPosition pos, Symbol sym, TypeSymbol c) { 1.24 + for (Type ct = c.type; ct != Type.noType ; ct = types.supertype(ct)) { 1.25 + for (Scope.Entry e = ct.tsym.members().lookup(sym.name); e.scope == ct.tsym.members(); e = e.next()) { 1.26 + // VM allows methods and variables with differing types 1.27 + if (sym.kind == e.sym.kind && 1.28 + types.isSameType(types.erasure(sym.type), types.erasure(e.sym.type)) && 1.29 + sym != e.sym && 1.30 + (sym.flags() & Flags.SYNTHETIC) != (e.sym.flags() & Flags.SYNTHETIC) && 1.31 + (sym.flags() & BRIDGE) == 0 && (e.sym.flags() & BRIDGE) == 0) { 1.32 + syntheticError(pos, (e.sym.flags() & SYNTHETIC) == 0 ? e.sym : sym); 1.33 + return; 1.34 + } 1.35 + } 1.36 + } 1.37 + } 1.38 + 1.39 + /** Report a conflict between a user symbol and a synthetic symbol. 1.40 + */ 1.41 + private void syntheticError(DiagnosticPosition pos, Symbol sym) { 1.42 + if (!sym.type.isErroneous()) { 1.43 + if (warnOnSyntheticConflicts) { 1.44 + log.warning(pos, "synthetic.name.conflict", sym, sym.location()); 1.45 + } 1.46 + else { 1.47 + log.error(pos, "synthetic.name.conflict", sym, sym.location()); 1.48 + } 1.49 + } 1.50 + } 1.51 + 1.52 /** Check that class c does not implement directly or indirectly 1.53 * the same parameterized interface with two different argument lists. 1.54 * @param pos Position to be used for error reporting.