# checkForAliasCircle method

1. @protected

void checkForAliasCircle(

1. String name,
2. String alias

)

Check whether the given name points back to the given alias as an alias in the other direction already, catching a circular reference.

## Parameters:

- `name`: The canonical name being registered
- `alias`: The alias being registered

## Throws:

- IllegalStateException if a circular reference is detected

## Example:

    final registry = SimpleAliasRegistry();
    registry.registerAlias('serviceA', 'serviceB');

    try {
      registry.registerAlias('serviceB', 'serviceA'); // Circular!
      // Throws: "Cannot register alias 'serviceA' for name 'serviceB':
      // Circular reference - 'serviceB' is a direct or indirect alias for
      // 'serviceA' already"
    } on IllegalStateException catch (e) {
      print('Circular reference prevented');
    }

## Implementation

    @protected
    void checkForAliasCircle(String name, String alias) {
      if (hasAlias(alias, name)) {
        throw IllegalStateException(
          "Cannot register alias '$alias' for name '$name': "
          "Circular reference - '$name' is a direct or indirect alias for "
          "'$alias' already"
        );
      }
    }