# findSuperClassAs<S> method

1. @override

Class<S>? findSuperClassAs<S>(

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

])
override

Finds and casts the superclass of a given `parentClass` to a specific type.

Type Parameters:

- `S`: The expected type of the superclass.

Parameters:

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

Returns:

- A typed Class<S> instance if found, or `null` otherwise.

## Example

    final listClass = await loader.loadClass<List>('dart:core/list.dart.List');
    final superIterable = loader.findSuperClassAs<Iterable>(listClass);
    print(superIterable?.qualifiedName); // e.g., "dart:core/iterable.dart.Iterable"

## Implementation

    @override
    Class<S>? findSuperClassAs<S>(Class parentClass, [bool declared = true]) {
      _checkClosed();

      final clazz = Class<S>();
      final cacheKey = "${_buildCacheKey(parentClass)}:${_buildCacheKey(clazz)}:superClass:$declared";

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

      _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 as Class<S>;
    }