< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java

Print this page




3433     boolean checkUnique(DiagnosticPosition pos, Symbol sym, Scope s) {
3434         if (sym.type.isErroneous())
3435             return true;
3436         if (sym.owner.name == names.any) return false;
3437         for (Symbol byName : s.getSymbolsByName(sym.name, NON_RECURSIVE)) {
3438             if (sym != byName &&
3439                     (byName.flags() & CLASH) == 0 &&
3440                     sym.kind == byName.kind &&
3441                     sym.name != names.error &&
3442                     (sym.kind != MTH ||
3443                      types.hasSameArgs(sym.type, byName.type) ||
3444                      types.hasSameArgs(types.erasure(sym.type), types.erasure(byName.type)))) {
3445                 if ((sym.flags() & VARARGS) != (byName.flags() & VARARGS)) {
3446                     sym.flags_field |= CLASH;
3447                     varargsDuplicateError(pos, sym, byName);
3448                     return true;
3449                 } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, byName.type, false)) {
3450                     duplicateErasureError(pos, sym, byName);
3451                     sym.flags_field |= CLASH;
3452                     return true;





3453                 } else {
3454                     duplicateError(pos, byName);
3455                     return false;
3456                 }
3457             }
3458         }
3459         return true;
3460     }
3461 
3462     /** Report duplicate declaration error.
3463      */
3464     void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) {
3465         if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) {
3466             log.error(pos, Errors.NameClashSameErasure(sym1, sym2));
3467         }
3468     }
3469 
3470     /**Check that types imported through the ordinary imports don't clash with types imported
3471      * by other (static or ordinary) imports. Note that two static imports may import two clashing
3472      * types without an error on the imports.




3433     boolean checkUnique(DiagnosticPosition pos, Symbol sym, Scope s) {
3434         if (sym.type.isErroneous())
3435             return true;
3436         if (sym.owner.name == names.any) return false;
3437         for (Symbol byName : s.getSymbolsByName(sym.name, NON_RECURSIVE)) {
3438             if (sym != byName &&
3439                     (byName.flags() & CLASH) == 0 &&
3440                     sym.kind == byName.kind &&
3441                     sym.name != names.error &&
3442                     (sym.kind != MTH ||
3443                      types.hasSameArgs(sym.type, byName.type) ||
3444                      types.hasSameArgs(types.erasure(sym.type), types.erasure(byName.type)))) {
3445                 if ((sym.flags() & VARARGS) != (byName.flags() & VARARGS)) {
3446                     sym.flags_field |= CLASH;
3447                     varargsDuplicateError(pos, sym, byName);
3448                     return true;
3449                 } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, byName.type, false)) {
3450                     duplicateErasureError(pos, sym, byName);
3451                     sym.flags_field |= CLASH;
3452                     return true;
3453                 } else if ((sym.flags() & MATCH_BINDING) != 0 &&
3454                            (byName.flags() & MATCH_BINDING) != 0 &&
3455                            (byName.flags() & MATCH_BINDING_TO_OUTER) == 0) {
3456                     //this error will be reported separatelly in MatchBindingsComputer
3457                     return false;
3458                 } else {
3459                     duplicateError(pos, byName);
3460                     return false;
3461                 }
3462             }
3463         }
3464         return true;
3465     }
3466 
3467     /** Report duplicate declaration error.
3468      */
3469     void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) {
3470         if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) {
3471             log.error(pos, Errors.NameClashSameErasure(sym1, sym2));
3472         }
3473     }
3474 
3475     /**Check that types imported through the ordinary imports don't clash with types imported
3476      * by other (static or ordinary) imports. Note that two static imports may import two clashing
3477      * types without an error on the imports.


< prev index next >