acceptsType method
Will return true if type can be cast to this type.
Note: This is similar to Java isInstance and isAssignableFrom.
Implementation
@override
bool acceptsType(ASTType type) {
// A `dynamic` key/value component acts as a wildcard, so an empty `{}`
// literal (typed `Map<dynamic,dynamic>`) is assignable to a typed map like
// `Map<String,int>`. Mirrors how lists ignore their element type here.
if (type is ASTTypeMap) {
bool accepts(ASTType a, ASTType b) =>
a is ASTTypeDynamic || b is ASTTypeDynamic || a.acceptsType(b);
if (accepts(keyType, type.keyType) &&
accepts(valueType, type.valueType)) {
return true;
}
}
return super.acceptsType(type);
}