Ejemplo n.º 1
0
  /** Check that the assignment to a local variable is correct. */
  protected void checkLocalAssign(
      FlowGraph graph, LocalAssign a, DataFlowItem dfIn, DataFlowItem dfOut)
      throws SemanticException {
    LocalInstance li = ((Local) a.left()).localInstance();
    if (!currCBI.localDeclarations.contains(li)) {
      throw new SemanticException(
          "Final local variable \"" + li.name() + "\" cannot be assigned to in an inner class.",
          a.position());
    }

    MinMaxInitCount initCount = (MinMaxInitCount) dfOut.initStatus.get(li);

    if (li.flags().isFinal() && InitCount.MANY.equals(initCount.getMax())) {
      throw new SemanticException(
          "variable \"" + li.name() + "\" might already have been assigned to", a.position());
    }
  }