History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-25377
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Bas Leijdekkers
Reporter: Andrea Baroncelli
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

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

Created: 20 Mar 08 17:16   Updated: 20 Mar 08 22:54
Component/s: Code Analysis. Inspection
Fix Version/s: Selena 7.0.4

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Windows XP
Issue Links:
Relates
This issue relates to:
IDEADEV-22993 Replace with for loop intention break... Normal Resolved
 

Build: 7,757
Fixed in build: 8,242
Severity: Medium


 Description  « Hide
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



 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.