1666 if (m.overrides(e.sym, origin, types, false)) { |
1666 if (m.overrides(e.sym, origin, types, false)) { |
1667 if ((e.sym.flags() & ABSTRACT) == 0) { |
1667 if ((e.sym.flags() & ABSTRACT) == 0) { |
1668 checkOverride(tree, m, (MethodSymbol)e.sym, origin); |
1668 checkOverride(tree, m, (MethodSymbol)e.sym, origin); |
1669 } |
1669 } |
1670 } |
1670 } |
1671 else if (!checkNameClash(origin, e.sym, m)) { |
|
1672 log.error(tree, |
|
1673 "name.clash.same.erasure.no.override", |
|
1674 m, m.location(), |
|
1675 e.sym, e.sym.location()); |
|
1676 } |
|
1677 e = e.next(); |
1671 e = e.next(); |
1678 } |
1672 } |
1679 } |
1673 } |
1680 |
1674 |
1681 private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) { |
1675 private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) { |
2020 } |
2014 } |
2021 } |
2015 } |
2022 } |
2016 } |
2023 } |
2017 } |
2024 |
2018 |
|
2019 /** Check that all non-override equivalent methods accessible from 'site' |
|
2020 * are mutually compatible (JLS 8.4.8/9.4.1). |
|
2021 * |
|
2022 * @param pos Position to be used for error reporting. |
|
2023 * @param site The class whose methods are checked. |
|
2024 * @param sym The method symbol to be checked. |
|
2025 */ |
|
2026 void checkClashes(DiagnosticPosition pos, Type site, Symbol sym) { |
|
2027 List<Type> supertypes = types.closure(site); |
|
2028 for (List<Type> l = supertypes; l.nonEmpty(); l = l.tail) { |
|
2029 for (List<Type> m = supertypes; m.nonEmpty(); m = m.tail) { |
|
2030 checkClashes(pos, l.head, m.head, site, sym); |
|
2031 } |
|
2032 } |
|
2033 } |
|
2034 |
|
2035 /** Reports an error whenever 'sym' seen as a member of type 't1' clashes with |
|
2036 * some unrelated method defined in 't2'. |
|
2037 */ |
|
2038 private void checkClashes(DiagnosticPosition pos, Type t1, Type t2, Type site, Symbol s1) { |
|
2039 ClashFilter cf = new ClashFilter(site); |
|
2040 s1 = ((MethodSymbol)s1).implementedIn(t1.tsym, types); |
|
2041 if (s1 == null) return; |
|
2042 Type st1 = types.memberType(site, s1); |
|
2043 for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name, cf); e2.scope != null; e2 = e2.next(cf)) { |
|
2044 Symbol s2 = e2.sym; |
|
2045 if (s1 == s2) continue; |
|
2046 Type st2 = types.memberType(site, s2); |
|
2047 if (!types.overrideEquivalent(st1, st2) && |
|
2048 !checkNameClash((ClassSymbol)site.tsym, s1, s2)) { |
|
2049 log.error(pos, |
|
2050 "name.clash.same.erasure.no.override", |
|
2051 s1, s1.location(), |
|
2052 s2, s2.location()); |
|
2053 } |
|
2054 } |
|
2055 } |
|
2056 //where |
|
2057 private class ClashFilter implements Filter<Symbol> { |
|
2058 |
|
2059 Type site; |
|
2060 |
|
2061 ClashFilter(Type site) { |
|
2062 this.site = site; |
|
2063 } |
|
2064 |
|
2065 public boolean accepts(Symbol s) { |
|
2066 return s.kind == MTH && |
|
2067 (s.flags() & SYNTHETIC) == 0 && |
|
2068 s.isInheritedIn(site.tsym, types) && |
|
2069 !s.isConstructor(); |
|
2070 } |
|
2071 } |
|
2072 |
2025 /** Report a conflict between a user symbol and a synthetic symbol. |
2073 /** Report a conflict between a user symbol and a synthetic symbol. |
2026 */ |
2074 */ |
2027 private void syntheticError(DiagnosticPosition pos, Symbol sym) { |
2075 private void syntheticError(DiagnosticPosition pos, Symbol sym) { |
2028 if (!sym.type.isErroneous()) { |
2076 if (!sym.type.isErroneous()) { |
2029 if (warnOnSyntheticConflicts) { |
2077 if (warnOnSyntheticConflicts) { |