Regression: valid enhanced for loops no longer compile

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P2
    • 6
    • Affects Version/s: 6
    • Component/s: tools
    • generic
    • generic

      The testing for foreach loops was made too restrictive; this code compiled in build 68 and earlier:

          public Void scan(Iterable<? extends Tree> trees, Object o) {
              if (!found && trees == null)
                  for (Tree tree : trees)
                      if (!found)
                          scan(tree, o);
              return null;
          }

      but fails in build 70 with "foreach not applicable to expression type". Since trees is a collection of instances of type Tree or subclasses of type Tree, any element of that collection can safely be assigned to the foreach tree variable.

            Assignee:
            Unassigned
            Reporter:
            Tom Ball (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: