use of com.sun.tools.apt.mirror.declaration.DeclarationImpl in project ceylon-compiler by ceylon.
the class DeclarationsImpl method hides.
/**
* {@inheritDoc}
* See sections 8.3 and 8.4.6 of
* <cite>The Java™ Language Specification</cite>
*/
public boolean hides(MemberDeclaration sub, MemberDeclaration sup) {
Symbol hider = ((DeclarationImpl) sub).sym;
Symbol hidee = ((DeclarationImpl) sup).sym;
// Names must match. Nothing hides itself (just try it).
if (hider == hidee || hider.kind != hidee.kind || hider.name != hidee.name) {
return false;
}
// Methods only hide methods with matching signatures.
if (hider.kind == MTH) {
if ((hider.flags() & Flags.STATIC) == 0 || !env.jctypes.isSubSignature(hider.type, hidee.type)) {
return false;
}
}
// Hider must be in a subclass of hidee's class.
// Note that if M1 hides M2, and M2 hides M3, and M3 is accessible
// in M1's class, then M1 and M2 both hide M3.
ClassSymbol hiderClass = hider.owner.enclClass();
ClassSymbol hideeClass = hidee.owner.enclClass();
if (hiderClass == null || hideeClass == null || !hiderClass.isSubClass(hideeClass, env.jctypes)) {
return false;
}
// The method isInheritedIn is poorly named: it checks only access.
return hidee.isInheritedIn(hiderClass, env.jctypes);
}
Aggregations