예제 #1
0
  boolean isAsVisible(MethodBinding newMethod, MethodBinding inheritedMethod) {
    if (inheritedMethod.modifiers == newMethod.modifiers) return true;

    if (newMethod.isPublic()) return true; // Covers everything
    if (inheritedMethod.isPublic()) return false;

    if (newMethod.isProtected()) return true;
    if (inheritedMethod.isProtected()) return false;

    return !newMethod
        .isPrivate(); // The inheritedMethod cannot be private since it would not be visible
  }
예제 #2
0
 void checkConcreteInheritedMethod(MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
   // Remember that interfaces can only define public instance methods
   if (concreteMethod.isStatic())
     // Cannot inherit a static method which is specified as an instance method by an interface
     problemReporter().staticInheritedMethodConflicts(type, concreteMethod, abstractMethods);
   if (!concreteMethod.isPublic()) {
     int index = 0, length = abstractMethods.length;
     if (concreteMethod.isProtected()) {
       for (; index < length; index++) if (abstractMethods[index].isPublic()) break;
     } else if (concreteMethod.isDefault()) {
       for (; index < length; index++) if (!abstractMethods[index].isDefault()) break;
     }
     if (index < length)
       problemReporter().inheritedMethodReducesVisibility(type, concreteMethod, abstractMethods);
   }
 }