TypeReflection<T>.from constructor

TypeReflection<T>.from(
  1. Object o
)

Implementation

factory TypeReflection.from(Object o) {
  if (o is TypeReflection) {
    return o as TypeReflection<T>;
  } else if (o is Type) {
    return TypeReflection<T>._(o, null, TypeInfo.from(o));
  } else if (o is TypeInfo) {
    return TypeReflection<T>._(o.type, o.arguments, o);
  } else if (o is List<Type>) {
    var t = o[0];
    if (o.length > 1) {
      var args = o.sublist(1).map((e) => TypeInfo.from(e)).toList();
      return TypeReflection<T>._(t, args, TypeInfo<T>.from(t, args));
    } else {
      return TypeReflection<T>._(t, null, TypeInfo<T>.from(t));
    }
  } else {
    throw ArgumentError("Invalid type: $o");
  }
}