stdlib/public/runtime/ProtocolConformance.cpp
static
bool isRelatedType(const Metadata *type, const void *candidate,
                   bool candidateIsMetadata) {

  while (true) {
    if (type == candidate && candidateIsMetadata)
      return true;

    // If the type is resilient or generic, see if there's a witness table
    // keyed off the nominal type descriptor.
    const auto *description = type->getNominalTypeDescriptor();
    if (description == candidate && !candidateIsMetadata)
      return true;

    // If the type is a class, try its superclass.
    if (const ClassMetadata *classType = type->getClassObject()) {
      if (classHasSuperclass(classType)) {
        type = getMetadataForClass(classType->SuperClass);
        continue;
      }
    }

    break;
  }

  return false;
}
/// Checks if a given candidate is a type itself, one of its
/// superclasses or a related generic type.
///
/// This check is supposed to use the same logic that is used
/// by searchInConformanceCache.
///
/// \param candidate Pointer to a Metadata or a NominalTypeDescriptor.
///
Checks if a given candidate is a type itself, one of its
superclasses or a related generic type.

This check is supposed to use the same logic that is used
by searchInConformanceCache.

\param candidate Pointer to a Metadata or a NominalTypeDescriptor.
Checks if a given candidate is a type itself one of its superclasses or a related generic type . This check is supposed to use the same logic that is used by searchInConformanceCache . \ param candidate Pointer to a Metadata or a NominalTypeDescriptor .
static
bool isRelatedType(const Metadata *type, const void *candidate,
                   bool candidateIsMetadata) {
  while (true) {
    if (type == candidate && candidateIsMetadata)
      return true;
    const auto *description = type->getNominalTypeDescriptor();
    if (description == candidate && !candidateIsMetadata)
      return true;
    if (const ClassMetadata *classType = type->getClassObject()) {
      if (classHasSuperclass(classType)) {
        type = getMetadataForClass(classType->SuperClass);
        continue;
      }
    }
    break;
  }
  return false;
}
static bool isRelatedType ( const Metadata * type , const void * candidate , bool candidateIsMetadata ) { while ( true ) { if ( type == candidate && candidateIsMetadata ) return true ; const auto * description = type -> getNominalTypeDescriptor ( ) ; if ( description == candidate && ! candidateIsMetadata ) return true ; if ( const ClassMetadata * classType = type -> getClassObject ( ) ) { if ( classHasSuperclass ( classType ) ) { type = getMetadataForClass ( classType -> SuperClass ) ; continue ; } } break ; } return false ; }
Checks if a given candidate is a type itself, one of its
superclasses or a related generic type.
Checks if a given candidate is a type itself one of its superclasses or a related generic type .
// If the type is resilient or generic, see if there's a witness table // keyed off the nominal type descriptor. // If the type is a class, try its superclass.