public boolean tryAssignDepth(SortableType[] types) {
    int max;
    if (classDef.getSupertypeIndex() == ClassDef.NO_INDEX) {
      max = 0; // this is Object.class or an interface
    } else if (classDef.getSupertypeIndex() == classDef.getTypeIndex()) {
      // This is an invalid class extending itself.
      throw new DexException(
          "Class with type index " + classDef.getTypeIndex() + " extends itself");
    } else {
      SortableType sortableSupertype = types[classDef.getSupertypeIndex()];
      if (sortableSupertype == null) {
        max = 1; // unknown, so assume it's a root.
      } else if (sortableSupertype.depth == -1) {
        return false;
      } else {
        max = sortableSupertype.depth;
      }
    }

    for (short interfaceIndex : classDef.getInterfaces()) {
      SortableType implemented = types[interfaceIndex];
      if (implemented == null) {
        max = Math.max(max, 1); // unknown, so assume it's a root.
      } else if (implemented.depth == -1) {
        return false;
      } else {
        max = Math.max(max, implemented.depth);
      }
    }

    depth = max + 1;
    return true;
  }
Assigns this type's depth if the depths of its supertype and implemented interfaces are known.
Returns false if the depth couldn't be computed yet.
android/android_framework/dex-maker/src/main/java/com/android/dx/merge/SortableType.java