private void checkFunction(
      JetDeclarationWithBody function, final @NotNull JetType expectedReturnType) {
    assert function instanceof JetDeclaration;

    JetExpression bodyExpression = function.getBodyExpression();
    if (bodyExpression == null) return;
    JetFlowInformationProvider flowInformationProvider =
        new JetFlowInformationProvider((JetDeclaration) function, trace);

    boolean isPropertyAccessor = function instanceof JetPropertyAccessor;
    if (!isPropertyAccessor) {
      flowInformationProvider.recordInitializedVariables();
    }

    if (topDownAnalysisParameters.isDeclaredLocally()) return;

    flowInformationProvider.checkDefiniteReturn(expectedReturnType);

    if (!isPropertyAccessor) {
      // Property accessor is checked through initialization of a class/object or package properties
      // (at 'checkDeclarationContainer')
      flowInformationProvider.markUninitializedVariables();
    }

    flowInformationProvider.markUnusedVariables();

    flowInformationProvider.markUnusedLiteralsInBlock();
  }
  private void checkDeclarationContainer(JetDeclarationContainer declarationContainer) {
    // A pseudocode of class/object initialization corresponds to a class/object
    // or initialization of properties corresponds to a package declared in a file
    JetFlowInformationProvider flowInformationProvider =
        new JetFlowInformationProvider((JetElement) declarationContainer, trace);
    flowInformationProvider.recordInitializedVariables();

    if (topDownAnalysisParameters.isDeclaredLocally()) return;

    flowInformationProvider.markUninitializedVariables();
  }