admitSubtypeCapability top-level constant Null safety

_AdmitSubtypeCapability const admitSubtypeCapability

Gives support for calling .reflect on subtypes of covered instances.

In other words, this capability makes it possible to obtain a mirror which is intended to mirror an instance of a target class C, but it is actually mirroring a reflectee of a proper subtype D of C.

Please note that this is a subtle situation that may easily cause confusing and unintended results. It is only intended for usage in cases where the associated size reductions are highly appreciated, and the subtle semantics clearly understood!

In particular, note that declarations of members in subtypes are ignored unless they implement or override a declaration in the target class or a supertype thereof. Also note that the method type on an InstanceMirror will throw an exception, because it will otherwise have to return a ClassMirror for the target class, and that would yield results which are plain wrong.

For more information about this potentially dangerous device, please refer to the design document. TODO(eernst) doc: Insert a link to the design document.


const admitSubtypeCapability = _AdmitSubtypeCapability();