docs: @Nullable
    private RequiredType resolveTypeFromClass(
        Type calledType, ClassSymbol clazzSymbol, String typeArgName, VisitorState state) {
      // Try on the class
      int tyargIndex = findTypeArgInList(clazzSymbol, typeArgName);
      if (tyargIndex != -1) {
        return RequiredType.create(
            extractTypeArgAsMemberOfSupertype(calledType, clazzSymbol, tyargIndex, state.getTypes()));
      }
  
      while (clazzSymbol.isInner()) {
        // class Foo<T> {
        //    class Bar {
        //      void something(@CW("T") Object o));
        //    }
        // }
        // new Foo<String>().new Bar().something(123); // should fail, 123 needs to match String
        ClassSymbol encloser = clazzSymbol.owner.enclClass();
        calledType = calledType.getEnclosingType();
        tyargIndex = findTypeArgInList(encloser, typeArgName);
        if (tyargIndex != -1) {
          if (calledType.getTypeArguments().isEmpty()) {
            // If the receiver is held in a reference without the enclosing class's type arguments, we
            // can't determine the required type:
            // new Foo<String>().new Bar().something(123); // Yep
            // Foo<String>.Bar bar = ...;
            // bar.something(123); // Yep
            // Foo.Bar bar = ...;
            // bar.something(123); // Nope (this call would be unchecked if arg was T)
            return null;
          }
          return RequiredType.create(calledType.getTypeArguments().get(tyargIndex));
        }
        clazzSymbol = encloser;
      }
      return null;
    }