private static boolean mayHaveNullTypeDueToPendingReference(@NotNull PsiExpression expression) {
    if (!(expression instanceof PsiReferenceExpression)) return false;
    PsiElement target = ((PsiReferenceExpression)expression).resolve();
    if (!(target instanceof PsiLocalVariable)) return false;
    PsiLocalVariable local = (PsiLocalVariable)target;
    if (!local.getTypeElement().isInferredType()) return false;
    PsiExpression initializer = local.getInitializer();
    if (initializer == null) return false;
    PsiType initializerType = initializer.getType();
    return initializerType == null && mayHaveUnknownTypeDueToPendingReference(initializer) ||
           PsiTypes.nullType().equals(initializerType) && mayHaveNullTypeDueToPendingReference(initializer);
  }
private static boolean mayHaveNullTypeDueToPendingReference(@NotNull PsiExpression expression)