Bug 123460 - [quick fix] gets confused with nested loops and generic lists
Summary: [quick fix] gets confused with nested loops and generic lists
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-11 11:28 EST by Nikolay Metchev CLA
Modified: 2009-01-23 11:34 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Metchev CLA 2006-01-11 11:28:53 EST
This applies to 3.1.1 and 3.2 M4.
in the example below use quickfix where indicated to create a local variable called "ans" and notice that it creates a List<B> instead of List<Integer>:
------------------------------------------------------
import java.util.List;

public abstract class A
{
   abstract List<B> getB();
   
   void m()
   {
      for (B b : getB())
      {
         for (Integer i : b.getI())
         {
            ans.add(i); //quickfix here
         }
      }
   }
}

interface B
{
   List<Integer> getI();
}
---------------------------------------------------------------------
Comment 1 Martin Aeschlimann CLA 2006-01-12 10:52:30 EST
Guessing of the correct variable type is a difficult thing anyways. Our trick is that we look at all existing types available in the current file. Here 'List<Integer>' seems to be around, so it should find that one.