-
Bug
-
Resolution: Not an Issue
-
P2
-
6
-
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.
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.