Get inferred nullness qualifiers for method-generic type variables at a callsite. When
inference is not possible for a given type variable, that type variable is not included in the
resulting map.
771099
public ImmutableMap<TypeVariableSymbol, Nullness> getNullnessGenerics(
      MethodInvocationTree callsite) {
    ImmutableMap.Builder<TypeVariableSymbol, Nullness> result = ImmutableMap.builder();
    for (TypeVariableSymbol tvs :
        TreeInfo.symbol((JCTree) callsite.getMethodSelect()).getTypeParameters()) {
      InferenceVariable iv = TypeVariableInferenceVar.create(tvs, callsite);
      if (constraintGraph.nodes().contains(iv)) {
        getNullness(iv).ifPresent(nullness -> result.put(tvs, nullness));
      }
    }
    return result.build();
  }
825863
private <T> void bindIfNotNull(final Class<T> interfaceType, @Nullable final Class<? extends T> implementationType, final Scope scope) {
        if (implementationType != null) {
            bind(interfaceType).to(implementationType).in(scope);
        }
    }
384962
public static String getVariableType(String type) throws IOException {
        if (getVariableTypes() != null) {
            String newType = getVariableTypes().get(type);
            if (newType != null)
                return newType;
        }
        return type;
    }
1108789
@Nullable
  public static MethodSymbol getSymbol(MethodInvocationTree tree) {
    Symbol sym = ASTHelpers.getSymbol(tree.getMethodSelect());
    if (!(sym instanceof MethodSymbol)) {
      // Defensive. Would only occur if there are errors in the AST.
      return null;
    }
    return (MethodSymbol) sym;
  }
1292947
private Description findShadowedTypes(
      Tree tree, List<? extends TypeParameterTree> typeParameters, VisitorState state) {

    Env<AttrContext> env =
        Enter.instance(state.context)
            .getEnv(ASTHelpers.getSymbol(state.findEnclosing(ClassTree.class)));

    Symtab symtab = state.getSymtab();
    PackageSymbol javaLang =
        symtab.enterPackage(symtab.java_base, Names.instance(state.context).java_lang);

    Iterable<Symbol> enclosingTypes = typesInEnclosingScope(env, javaLang);

    List<Symbol> shadowedTypes =
        typeParameters.stream()
            .map(
                param ->
                    Iterables.tryFind(
                            enclosingTypes,
                            sym ->
                                sym.getSimpleName()
                                    .equals(ASTHelpers.getType(param).tsym.getSimpleName()))
                        .orNull())
            .filter(Objects::nonNull)
            .collect(ImmutableList.toImmutableList());

    if (shadowedTypes.isEmpty()) {
      return Description.NO_MATCH;
    }

    Description.Builder descBuilder = buildDescription(tree);

    descBuilder.setMessage(buildMessage(shadowedTypes));

    Set<String> visibleNames =
        Streams.stream(Iterables.concat(env.info.getLocalElements(), enclosingTypes))
            .map(sym -> sym.getSimpleName().toString())
            .collect(ImmutableSet.toImmutableSet());

    SuggestedFix.Builder fixBuilder = SuggestedFix.builder();
    shadowedTypes.stream()
        .filter(tv -> TypeParameterNamingClassification.classify(tv.name.toString()).isValidName())
        .map(
            tv ->
                TypeParameterShadowing.renameTypeVariable(
                    TypeParameterShadowing.typeParameterInList(typeParameters, tv),
                    tree,
                    TypeParameterShadowing.replacementTypeVarName(tv.name, visibleNames),
                    state))
        .forEach(fixBuilder::merge);

    descBuilder.addFix(fixBuilder.build());
    return descBuilder.build();
  }
539828
public Iterable<VariableElement> getImplicitPostfixParams(TypeElement type) {
    if (ElementUtil.isEnum(type)) {
      return implicitEnumParams;
    }
    return Collections.emptyList();
  }
202859
def _has_nulltype(dt):
    
    if isinstance(dt, StructType):
        return any(_has_nulltype(f.dataType) for f in dt.fields)
    elif isinstance(dt, ArrayType):
        return _has_nulltype((dt.elementType))
    elif isinstance(dt, MapType):
        return _has_nulltype(dt.keyType) or _has_nulltype(dt.valueType)
    else:
        return isinstance(dt, NullType)
242598
public static Type resolveAt(Object o, TypeVariable<?> var) {
        Validate.notNull(var, "no variable to read");
        final GenericDeclaration genericDeclaration = var.getGenericDeclaration();
        Validate.isInstanceOf(Class.class, genericDeclaration, "%s is not declared by a Class",
            TypeUtils.toLongString(var));
        return resolveAt(o, var, TypeUtils.getTypeArguments(o.getClass(), (Class<?>) genericDeclaration));
    }
1175559
public NullnessStore getNullnessInfoBeforeNewContext(
      TreePath path, VisitorState state, Handler handler) {
    NullnessStore store = dataFlow.resultBefore(path, state.context, nullnessPropagation);
    if (store == null) {
      return NullnessStore.empty();
    }
    return store.filterAccessPaths(
        (ap) -> {
          if (ap.getElements().size() == 0) {
            AccessPath.Root root = ap.getRoot();
            if (!root.isReceiver()) {
              Element e = root.getVarElement();
              return e.getKind().equals(ElementKind.PARAMETER)
                  || e.getKind().equals(ElementKind.LOCAL_VARIABLE);
            }
          }

          return handler.includeApInfoInSavedContext(ap, state);
        }
135966
private static Map<TypeVariable<?>, Type> getAllAssignments(final Type t) {
        return spider(new TypeVariableMap(), new HashSet<>(), t);
    }
360122
private static Map<TypeVariable<?>, Type> getTypeArguments(Class<?> cls, final Class<?> toClass,
            final Map<TypeVariable<?>, Type> subtypeVarAssigns) {
        // make sure they're assignable
        if (!isAssignable(cls, toClass)) {
            return null;
        }

        // can't work with primitives
        if (cls.isPrimitive()) {
            // both classes are primitives?
            if (toClass.isPrimitive()) {
                // dealing with widening here. No type arguments to be
                // harvested with these two types.
                return new HashMap<>();
            }

            // work with wrapper the wrapper class instead of the primitive
            cls = ClassUtils.primitiveToWrapper(cls);
        }

        // create a copy of the incoming map, or an empty one if it's null
        final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
                : new HashMap<>(subtypeVarAssigns);

        // has target class been reached?
        if (toClass.equals(cls)) {
            return typeVarAssigns;
        }

        // walk the inheritance hierarchy until the target class is reached
        return getTypeArguments(getClosestParentType(cls, toClass), toClass, typeVarAssigns);
    }
410698
public Class resolveTypeVariable (TypeVariable typeVariable) {
		for (int i = argumentsSize - 2; i >= 0; i -= 2)
			if (arguments[i] == typeVariable) return (Class)arguments[i + 1];
		return null;
	}
892737
private static boolean hasTypeVariables(final Type type) {
        if (type instanceof TypeVariable<?> || type instanceof GenericArrayType) {
            return true;
        } else if (type instanceof ParameterizedType) {
            for (final Type arg : ((ParameterizedType) type).getActualTypeArguments()) {
                if (hasTypeVariables(arg)) {
                    return true;
                }
            }
        }
        return false;
    }
937923
public static Map<TypeVariable, Type> getTypeVariableMap(Class<?> clazz) {
		Map<TypeVariable, Type> typeVariableMap = typeVariableCache.get(clazz);

		if (typeVariableMap == null) {
			typeVariableMap = new HashMap<TypeVariable, Type>();

			// interfaces
			extractTypeVariablesFromGenericInterfaces(clazz.getGenericInterfaces(), typeVariableMap);

			try {
				// super class
				Class<?> type = clazz;
				while (type.getSuperclass() != null && !Object.class.equals(type.getSuperclass())) {
					Type genericType = type.getGenericSuperclass();
					if (genericType instanceof ParameterizedType) {
						ParameterizedType pt = (ParameterizedType) genericType;
						populateTypeMapFromParameterizedType(pt, typeVariableMap);
					}
					extractTypeVariablesFromGenericInterfaces(type.getSuperclass().getGenericInterfaces(), typeVariableMap);
					type = type.getSuperclass();
				}
			}
			catch (MalformedParameterizedTypeException ex) {
				// from getGenericSuperclass() - ignore and continue with member class check
			}

			try {
				// enclosing class
				Class<?> type = clazz;
				while (type.isMemberClass()) {
					Type genericType = type.getGenericSuperclass();
					if (genericType instanceof ParameterizedType) {
						ParameterizedType pt = (ParameterizedType) genericType;
						populateTypeMapFromParameterizedType(pt, typeVariableMap);
					}
					type = type.getEnclosingClass();
				}
			}
			catch (MalformedParameterizedTypeException ex) {
				// from getGenericSuperclass() - ignore and preserve previously accumulated type variables
			}

			typeVariableCache.put(clazz, typeVariableMap);
		}

		return typeVariableMap;
	}
405548
@SuppressWarnings("unchecked")
  public <T extends TypedValue> T getVariableLocalTyped(String variableName) {
    TypedValue variable = associationManager.getVariableLocal(variableName);
    return variable != null ? (T) variable : null;
  }
1096098
private List<Statement> getInitLocation(MethodDeclaration node) {
    List<Statement> stmts = node.getBody().getStatements();
    if (!stmts.isEmpty() && stmts.get(0) instanceof SuperConstructorInvocation) {
      return stmts.subList(0, 1);
    }
    // java.lang.Object supertype is null. All other types should have a super() call.
    assert TypeUtil.isNone(
        ElementUtil.getDeclaringClass(node.getExecutableElement()).getSuperclass())
        : "Constructor didn't have a super() call.";
    return stmts.subList(0, 0);
  }
828713
@SuppressWarnings("unchecked")
  public <T extends TypedValue> T getVariableTyped(String variableName) {
    TypedValue variable = associationManager.getVariable(variableName);
    return variable != null ? (T) (variable) : null;
  }