Priority
Major
Type
Bug 
State
Fixed 
Assignee
Bas Leijdekkers 
Subsystem
Code Analysis. Inspection 
Affected versions
Fixed in
Fixed in build
Next build 
Build
7757
Fixed in build
8242
Severity
0
  • Submitted by   Andrea Baroncelli
    22 months ago (20 Mar 2008 17:16)
  • Updated by   root
    3 weeks ago (17 Jan 2010 19:58)
  • Jira: IDEA-43179
    (history, comments)

IDEA-43179

Foreach refactoring can cause confusion in loop variables when applied to nested loops

0
Hi,

I noticed that automatic foreach refactoring does not work correctly when applied to nested loops like

static <T,S> void ideaBugDetector( final Iterable<T> iterable1, final Iterable<S> iterable2 ) {
    final Iterator<T> iterator1 = iterable1.iterator();
    while ( iterator1.hasNext() ) {
        final Iterator<S> iterator2 = iterable2.iterator();
        while ( iterator2.hasNext() ) {
            System.out.println( iterator1.next() + " " + iterator2.next() );
        }
    }
}


Either when performing it on the external or on the internal loop, this operation causes confusion in inner and outer loop variables.
Regards,

Andrea

Environment: Windows XP

Issue was resolved
Comments (0)
 
History (1)
 
Links
 
Issue has no comments