code: @SuppressWarnings("unchecked")
      public static <T> T getAsType(Object self, Class<T> clazz) {
          if (self instanceof GeneratedGroovyProxy) {
              Object proxyTarget = ((GeneratedGroovyProxy)self).getProxyTarget();
              if (clazz.isAssignableFrom(proxyTarget.getClass())) {
                  return (T) proxyTarget;
              }
          }
          return DefaultGroovyMethods.asType(self, clazz);
      }
docs: Converts a class implementing some trait into a target class. If the trait is a dynamic proxy and
  that the target class is assignable to the target object of the proxy, then the target object is
  returned. Otherwise, falls back to {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#asType(java.lang.Object, Class)}
  @param self an object to be coerced to some class
  @param clazz the class to be coerced to
  @return the object coerced to the target class, or the proxy instance if it is compatible with the target class.