docs: @SuppressWarnings("unchecked")
    public static <T> T newInstance(Type type, Object... arguments)
    {
      if(type instanceof ParameterizedType) {
        ParameterizedType t = (ParameterizedType)type;
        if(!(t.getRawType() instanceof Class<?>)) {
          throw new BugError("Raw type for parameterized type should be a class but is |%s|.", t.getRawType());
        }
        Class<?> rawClass = (Class<?>)t.getRawType();
        if(rawClass.isInterface()) {
          if(Types.isCollection(rawClass)) {
            return newCollection(rawClass);
          }
          if(Types.isMap(rawClass)) {
            return newMap(rawClass);
          }
        }
        return newInstance(t.getRawType(), arguments);
      }
  
      if(type instanceof Class) {
        return (T)newInstance((Class<?>)type, arguments);
      }
  
      throw new BugError("Cannot create new instance for type |%s|.", type);
    }