Determine if a {@link ScopeType} is an ancestor of another {@link ScopeType}.
502658
public static <S extends ScopeType<S>> boolean isScopeTypeAncestor(S scopeType, S possibleAncestor) {
    Queue<S> ancestors = new LinkedList<>();
    ancestors.add(scopeType);
    while (true) {
      if (ancestors.isEmpty()) {
        return false;
      }
      if (ancestors.peek().equals(possibleAncestor)) {
        return true;
      }
      Collection<S> parentScopes = ancestors.poll().parentScopes();
      if (parentScopes != null) {
        ancestors.addAll(parentScopes);
      }
    }
  }
118178
private static boolean isSubtype(
      ObjectType typeA,
      RecordType typeB,
      ImplCache implicitImplCache,
      SubtypingMode subtypingMode) {

    MatchStatus cached = implicitImplCache.checkCache(typeA, typeB);
    if (cached != null) {
      return cached.subtypeValue();
    }

    boolean result =
        isStructuralSubtypeHelper(
            typeA, typeB, implicitImplCache, subtypingMode, ALL_PROPS_ARE_REQUIRED);
    return implicitImplCache.updateCache(typeA, typeB, MatchStatus.valueOf(result));
  }
343001
function isReliableScope(scope: OriginalScope): boolean {
  let totalBindings = 0;
  let unknownBindings = 0;

  for (let s = scope; s; s = s.parent) {
    const vars = (s.bindings && s.bindings.variables) || {};
    for (const key of Object.keys(vars)) {
      const binding = vars[key];

      totalBindings += 1;
      if (
        binding.value &&
        typeof binding.value === "object" &&
        (binding.value.type === "unscoped" || binding.value.type === "unmapped")
      ) {
        unknownBindings += 1;
      }
    }
  }

  // As determined by fair dice roll.
  return totalBindings === 0 || unknownBindings / totalBindings < 0.25;
}
1058850
<T> InjectScope<T> scope(Class<? extends Annotation> scopeType)
  {
    Supplier<InjectScope<T>> scopeGen = (Supplier) _scopeMap.get(scopeType);

    if (scopeGen == null) {
      throw error("{0} is an unknown scope",
                  scopeType.getSimpleName());
    }

    return scopeGen.get();
  }
519885
private boolean ensurePropertyDeclaredHelper(
      Node getprop, ObjectType objectType, FlowScope scope) {
    if (getprop.isQualifiedName()) {
      String propName = getprop.getLastChild().getString();
      String qName = getprop.getQualifiedName();
      TypedVar var = getDeclaredVar(scope, qName);
      if (var != null && !var.isTypeInferred()) {
        // Handle normal declarations that could not be addressed earlier.
        if (propName.equals("prototype")
            ||
            // Handle prototype declarations that could not be addressed earlier.
            (!objectType.hasOwnProperty(propName)
                && (!objectType.isInstanceType()
                    || (var.isExtern() && !objectType.isNativeObjectType())))) {
          return objectType.defineDeclaredProperty(
              propName, var.getType(), getprop);
        }
      }
    }
    return false;
  }
406652
function (testFn) {
            var ancestor = this;
            while (ancestor.parentView) {
                ancestor = ancestor.parentView;
                if (ancestor && testFn(ancestor)) {
                    return ancestor;
                }
            }
            return null;
        }
1196329
def is_inheritance_parent(self, field):
        '''
        
        '''
        return (
            isinstance(field, related.OneToOneField) and
            field.primary_key and
            issubclass(field.model, get_remote_field_to(field))
        )
220059
public boolean isGeneralInstance()
    {
        boolean ret = true;
        if (this.generalInstance != null) {
            ret = this.generalInstance;
        } else if (getParentType() != null) {
            ret = getParentType().isGeneralInstance();
        }
        return ret;
    }
1213322
def is_ancestor(self, child_key_name, ancestor_key_name):
        """"""

        # all keys are descendents of None
        if ancestor_key_name is None:
            return True

        one_up_parent = self.dct[child_key_name]['parent']
        if child_key_name == ancestor_key_name:
            # debatable semantics, but a person lies in his/her own
            # ancestry tree
            return True
        elif one_up_parent is None:
            return False
        else:
            return self.is_ancestor(one_up_parent, ancestor_key_name)
221242
public boolean isSubtypeOf(JvmType type) {
		if (type == null) {
			throw new IllegalArgumentException("type may not be null");
		}
		// TODO interfaces don't inherit from non-interfaces, primitives, arrays, object
		// A final type does not have any subtypes
		// check for type == this.type
		LightweightTypeReference other = owner.toPlainTypeReference(type);
		boolean result = other.isAssignableFrom(this);
		return result;
	}
842147
private boolean isValidTreeType(Tree t) {
    if (t instanceof LambdaExpressionTree) {
      return true;
    }
    if (t instanceof ClassTree) {
      NestingKind nestingKind = ASTHelpers.getSymbol((ClassTree) t).getNestingKind();
      return nestingKind.equals(NestingKind.ANONYMOUS) || nestingKind.equals(NestingKind.LOCAL);
    }
    return false;
  }
300108
function isAncestorIDOf(ancestorID, descendantID) {
  return (
    descendantID.indexOf(ancestorID) === 0 &&
    isBoundary(descendantID, ancestorID.length)
  );
}
1106027
def has_superclass?(child, ancestor)
      if child.superclass == ancestor
        true
      elsif child.superclass.nil?
        false
      else
        has_superclass?(child.superclass, ancestor)
      end
    end
339613
public static boolean isInstance(Type a, Type b) {
    if (a instanceof Class<?>) {
      return a.equals(b);
    } else if (a instanceof GenericArrayType) {
      if (b instanceof GenericArrayType) {
        return isInstance(
            ((GenericArrayType) a).getGenericComponentType(),
            ((GenericArrayType) b).getGenericComponentType());
      } else {
        return false;
      }
    } else if (a instanceof ParameterizedType) {
      if (!(b instanceof ParameterizedType)) {
        return false;
      }
      ParameterizedType parameterizedTypeA = (ParameterizedType) a;
      ParameterizedType parameterizedTypeB = (ParameterizedType) b;
      Type[] actualTypeArgumentsA = parameterizedTypeA.getActualTypeArguments();
      Type[] actualTypeArgumentsB = parameterizedTypeB.getActualTypeArguments();
      if (!parameterizedTypeA.getRawType().equals(parameterizedTypeB.getRawType()) ||
          actualTypeArgumentsA.length != actualTypeArgumentsB.length) {
        return false;
      }
      for (int i = 0; i < actualTypeArgumentsA.length; i++) {
        if (!isInstance(actualTypeArgumentsA[i], actualTypeArgumentsB[i])) {
          return false;
        }
      }
      return true;
    } else if (a instanceof TypeVariable<?>) {
      TypeVariable<?> typeVariable = (TypeVariable<?>) a;
      for (Type bound : typeVariable.getBounds()) {
        return isAssignableFrom(bound, b);
      }
      return true;
    } else if (a instanceof WildcardType) {
      WildcardType wildcardType = (WildcardType) a;
      for (Type lowerBound : wildcardType.getLowerBounds()) {
        if (!isAssignableFrom(b, lowerBound)) {
          return false;
        }
      }
      for (Type upperBound : wildcardType.getUpperBounds()) {
        if (!isAssignableFrom(upperBound, b)) {
          return false;
        }
      }
      return true;
    }
    throw new IllegalStateException();
  }
931979
@Override
    public List<? extends Tree> getAncestors() {
        if ( getParent()==null ) return null;
        List<Tree> ancestors = new ArrayList<Tree>();
        Tree t = this;
        t = t.getParent();
        while ( t!=null ) {
            ancestors.add(0, t); // insert at start
            t = t.getParent();
        }
        return ancestors;
    }
369647
def is_ancestor(self, commit1, commit2, patch=False):
        """"""
        result = self.hg("log", "-r", "first(%s::%s)" % (commit1, commit2),
                         "--template", "exists", patch=patch)
        return "exists" in result
1226062
public final <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target> boolean hasRelationship(final Class<? extends Relation<A, B, S, T>> type) {
		return this.getRelationships(type).iterator().hasNext();
	}