# findSuperClass method

1. @override

Class? findSuperClass(

1. Class parentClass, [
2. bool declared = true

])
override

Finds the superclass of a given `parentClass`.

Parameters:

- `parentClass`: The class whose superclass should be located.
- `declared`: If `true` (default), returns the directly declared superclass only.
  If `false`, returns the nearest superclass in the hierarchy.

Returns:

- The superclass Class instance, or `null` if none exists.

## Example

    final dogClass = await loader.loadClass<Dog>('package:example/test.dart.Dog');
    final superClass = loader.findSuperClass(dogClass);
    print(superClass?.qualifiedName); // e.g., "package:example/test.dart.Animal"

## Usage Notes

- Declared mode is useful for analyzing direct inheritance.
- Non-declared mode is helpful for traversing extended hierarchies.

## Implementation

    @override
    Class? findSuperClass(Class parentClass, [bool declared = true]) {
      _checkClosed();

      final cacheKey = "${_buildCacheKey(parentClass)}:superClass:$declared";

      // Check cache first
      final cached = _superClassCache[cacheKey];
      if (cached != null) {
        _hitCount++;
        return cached;
      }

      _missCount++;

      // Compute classes
      final link = parentClass.getTypeDeclaration().asClass()?.getSuperClass();
      if (link == null) return null;

      final result = _getFromLink(link, parentClass.getProtectionDomain(), useType: declared);

      // Cache result
      _superClassCache[cacheKey] = result;

      return result;
    }