63 private final Target target; |
63 private final Target target; |
64 private final Source source; |
64 private final Source source; |
65 private final Types types; |
65 private final Types types; |
66 private final JCDiagnostic.Factory diags; |
66 private final JCDiagnostic.Factory diags; |
67 private final boolean skipAnnotations; |
67 private final boolean skipAnnotations; |
|
68 private boolean warnOnSyntheticConflicts; |
68 private final TreeInfo treeinfo; |
69 private final TreeInfo treeinfo; |
69 |
70 |
70 // The set of lint options currently in effect. It is initialized |
71 // The set of lint options currently in effect. It is initialized |
71 // from the context, and then is set/reset as needed by Attr as it |
72 // from the context, and then is set/reset as needed by Attr as it |
72 // visits all the various parts of the trees during attribution. |
73 // visits all the various parts of the trees during attribution. |
97 Source source = Source.instance(context); |
98 Source source = Source.instance(context); |
98 allowGenerics = source.allowGenerics(); |
99 allowGenerics = source.allowGenerics(); |
99 allowAnnotations = source.allowAnnotations(); |
100 allowAnnotations = source.allowAnnotations(); |
100 complexInference = options.get("-complexinference") != null; |
101 complexInference = options.get("-complexinference") != null; |
101 skipAnnotations = options.get("skipAnnotations") != null; |
102 skipAnnotations = options.get("skipAnnotations") != null; |
|
103 warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null; |
102 |
104 |
103 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); |
105 boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); |
104 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); |
106 boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); |
105 boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings(); |
107 boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings(); |
106 |
108 |
1707 return; |
1709 return; |
1708 } |
1710 } |
1709 checkCompatibleConcretes(pos, c); |
1711 checkCompatibleConcretes(pos, c); |
1710 } |
1712 } |
1711 |
1713 |
|
1714 void checkConflicts(DiagnosticPosition pos, Symbol sym, TypeSymbol c) { |
|
1715 for (Type ct = c.type; ct != Type.noType ; ct = types.supertype(ct)) { |
|
1716 for (Scope.Entry e = ct.tsym.members().lookup(sym.name); e.scope == ct.tsym.members(); e = e.next()) { |
|
1717 // VM allows methods and variables with differing types |
|
1718 if (sym.kind == e.sym.kind && |
|
1719 types.isSameType(types.erasure(sym.type), types.erasure(e.sym.type)) && |
|
1720 sym != e.sym && |
|
1721 (sym.flags() & Flags.SYNTHETIC) != (e.sym.flags() & Flags.SYNTHETIC) && |
|
1722 (sym.flags() & BRIDGE) == 0 && (e.sym.flags() & BRIDGE) == 0) { |
|
1723 syntheticError(pos, (e.sym.flags() & SYNTHETIC) == 0 ? e.sym : sym); |
|
1724 return; |
|
1725 } |
|
1726 } |
|
1727 } |
|
1728 } |
|
1729 |
|
1730 /** Report a conflict between a user symbol and a synthetic symbol. |
|
1731 */ |
|
1732 private void syntheticError(DiagnosticPosition pos, Symbol sym) { |
|
1733 if (!sym.type.isErroneous()) { |
|
1734 if (warnOnSyntheticConflicts) { |
|
1735 log.warning(pos, "synthetic.name.conflict", sym, sym.location()); |
|
1736 } |
|
1737 else { |
|
1738 log.error(pos, "synthetic.name.conflict", sym, sym.location()); |
|
1739 } |
|
1740 } |
|
1741 } |
|
1742 |
1712 /** Check that class c does not implement directly or indirectly |
1743 /** Check that class c does not implement directly or indirectly |
1713 * the same parameterized interface with two different argument lists. |
1744 * the same parameterized interface with two different argument lists. |
1714 * @param pos Position to be used for error reporting. |
1745 * @param pos Position to be used for error reporting. |
1715 * @param type The type whose interfaces are checked. |
1746 * @param type The type whose interfaces are checked. |
1716 */ |
1747 */ |