code: private boolean verifyTypes()
      {
          SuccessAndResult<ThriftType> output = topologicalSort(thriftTypes, new Predicate<ThriftType>()
          {
              @Override
              public boolean apply(@Nullable ThriftType t)
              {
                  ThriftProtocolType proto = checkNotNull(t).getProtocolType();
                  if (proto == ThriftProtocolType.ENUM || proto == ThriftProtocolType.STRUCT) {
                      return verifyStruct(t, true);
                  } else {
                      Preconditions.checkState(false, "Top-level non-enum and non-struct?");
                      return false;   // silence compiler
                  }
              }
          });
          if (output.success) {
              thriftTypes = output.result;
              return true;
          } else {
              for (ThriftType t: output.result) {
                  // we know it's gonna fail, we just want the precise error message
                  verifyStruct(t, false);
              }
              return false;
          }
      }
docs: and does a topological sort of thriftTypes in dependency order