isAssignableTo method
Checks the assignability relationship, denoted by <=> in the language
specification.
This is the type relationship tested on assignment in checked mode.
Note that this method can only be invoked successfully if all the
supertypes of the receiver and other are covered by the reflector,
and a TypeRelationsCapability has been requested.
Required capabilities: assignAbleTo requires a
TypeRelationsCapability, and it requires that all the types visited in
order to determine the result must be covered.
Implementation
@override
bool isAssignableTo(TypeMirror other) {
if (_superclassIndex == noCapabilityIndex) {
// There are two possible reasons for this: (1) If we have no type
// relations capability then the index will always be noCapabilityIndex.
// (2) Even if we have the type relations capability then the superclass
// may be un-covered. So we cannot tell the two apart based on index.
// Note that the check for superclass access also applies to the access
// to superinterfaces, that is, it is not necessary (nor useful) to check
// for access to superinterfaces here.
if (!_supportsTypeRelations(_reflector)) {
throw NoSuchCapabilityError(
'Attempt to evaluate `isAssignableTo` for `$qualifiedName` '
'without `typeRelationsCapability`',
);
}
throw NoSuchCapabilityError(
'Attempt to evaluate `isAssignableTo` for `$qualifiedName` '
'without capability.',
);
}
return _isSubtypeOf(other) ||
(other is ClassMirrorBase && other._isSubtypeOf(this));
}