enum Mirror.AncestorRepresentation

The representation to use for ancestor classes.

A class that conforms to the CustomReflectable protocol can control how its mirror represents ancestor classes by initializing the mirror with an AncestorRepresentation. This setting has no effect on mirrors reflecting value type instances.

Import import Swift


case generated

Generates a default mirror for all ancestor classes.

This case is the default when initializing a Mirror instance.

When you use this option, a subclass's mirror generates default mirrors even for ancestor classes that conform to the CustomReflectable protocol. To avoid dropping the customization provided by ancestor classes, an override of customMirror should pass .customized({ super.customMirror }) as ancestorRepresentation when initializing its mirror.


case customized(@escaping () -> Mirror)

Uses the nearest ancestor's implementation of customMirror to create a mirror for that ancestor.

Other classes derived from such an ancestor are given a default mirror. The payload for this option should always be { super.customMirror }:

var customMirror: Mirror {
    return Mirror(
        children: ["someProperty": self.someProperty],
        ancestorRepresentation: .customized({ super.customMirror })) // <==


case suppressed

Suppresses the representation of all ancestor classes.

In a mirror created with this ancestor representation, the superclassMirror property is nil.