code: Iterable<TypeSymbol> superclasses(final Type intype) {
          return new Iterable<TypeSymbol>() {
              public Iterator<TypeSymbol> iterator() {
                  return new Iterator<TypeSymbol>() {
  
                      List<TypeSymbol> seen = List.nil();
                      TypeSymbol currentSym = symbolFor(intype);
                      TypeSymbol prevSym = null;
  
                      public boolean hasNext() {
                          if (currentSym == syms.noSymbol) {
                              currentSym = symbolFor(types.supertype(prevSym.type));
                          }
                          return currentSym != null;
                      }
  
                      public TypeSymbol next() {
                          prevSym = currentSym;
                          currentSym = syms.noSymbol;
                          Assert.check(prevSym != null || prevSym != syms.noSymbol);
                          return prevSym;
                      }
  
                      public void remove() {
                          throw new UnsupportedOperationException();
                      }
  
                      TypeSymbol symbolFor(Type t) {
                          if (!t.hasTag(CLASS) &&
                                  !t.hasTag(TYPEVAR)) {
                              return null;
                          }
                          while (t.hasTag(TYPEVAR))
                              t = t.getUpperBound();
                          if (seen.contains(t.tsym)) {
                              //degenerate case in which we have a circular
                              //class hierarchy - because of ill-formed classfiles
                              return null;
                          }
                          seen = seen.prepend(t.tsym);
                          return t.tsym;
                      }
                  };
              }
          };
      }
docs: Return an Iterable object to scan the superclasses of a given type.
  It's crucial that the scan is done lazily, as we don't want to accidentally
  access more supertypes than strictly needed (as this could trigger completion
  errors if some of the not-needed supertypes are missing/ill-formed).