2579 if (sym.type.isErroneous()) |
2579 if (sym.type.isErroneous()) |
2580 return true; |
2580 return true; |
2581 if (sym.owner.name == names.any) return false; |
2581 if (sym.owner.name == names.any) return false; |
2582 for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { |
2582 for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { |
2583 if (sym != e.sym && |
2583 if (sym != e.sym && |
|
2584 (e.sym.flags() & CLASH) == 0 && |
2584 sym.kind == e.sym.kind && |
2585 sym.kind == e.sym.kind && |
2585 sym.name != names.error && |
2586 sym.name != names.error && |
2586 (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { |
2587 (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { |
2587 if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) |
2588 if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { |
2588 varargsDuplicateError(pos, sym, e.sym); |
2589 varargsDuplicateError(pos, sym, e.sym); |
2589 else if (sym.kind == MTH && !types.overrideEquivalent(sym.type, e.sym.type)) |
2590 return true; |
|
2591 } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) { |
2590 duplicateErasureError(pos, sym, e.sym); |
2592 duplicateErasureError(pos, sym, e.sym); |
2591 else |
2593 sym.flags_field |= CLASH; |
|
2594 return true; |
|
2595 } else { |
2592 duplicateError(pos, e.sym); |
2596 duplicateError(pos, e.sym); |
2593 return false; |
2597 return false; |
|
2598 } |
2594 } |
2599 } |
2595 } |
2600 } |
2596 return true; |
2601 return true; |
2597 } |
2602 } |
2598 //where |
2603 //where |
2599 /** Report duplicate declaration error. |
2604 boolean hasSameSignature(Type mt1, Type mt2) { |
2600 */ |
2605 if (mt1.tag == FORALL && mt2.tag == FORALL) { |
2601 void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { |
2606 ForAll fa1 = (ForAll)mt1; |
2602 if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { |
2607 ForAll fa2 = (ForAll)mt2; |
2603 log.error(pos, "name.clash.same.erasure", sym1, sym2); |
2608 mt2 = types.subst(fa2, fa2.tvars, fa1.tvars); |
2604 } |
2609 } |
2605 } |
2610 return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType()); |
|
2611 } |
|
2612 |
|
2613 /** Report duplicate declaration error. |
|
2614 */ |
|
2615 void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { |
|
2616 if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { |
|
2617 log.error(pos, "name.clash.same.erasure", sym1, sym2); |
|
2618 } |
|
2619 } |
2606 |
2620 |
2607 /** Check that single-type import is not already imported or top-level defined, |
2621 /** Check that single-type import is not already imported or top-level defined, |
2608 * but make an exception for two single-type imports which denote the same type. |
2622 * but make an exception for two single-type imports which denote the same type. |
2609 * @param pos Position for error reporting. |
2623 * @param pos Position for error reporting. |
2610 * @param sym The symbol. |
2624 * @param sym The symbol. |