Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330241

Summary: [quick fix] 'Add unimplemented methods' adds two methods from its implementing interface when one is already there
Product: [Eclipse Project] JDT Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Fix none

Description Remy Suen CLA 2010-11-15 08:43:09 EST
I20101102-0800

1. Make a new Java 5 project.
2. Make one file.

import java.util.List;
public interface EModelService {
  public <T> List<T> findElements(Class<T> clazz, List<String> tagsToMatch);

  public <T> List<T> findPerspectiveElements(Class<T> clazz,
      List<String> tagsToMatch);
}

3. Make another file. This one will have errors.

import java.util.List;
public class ModelServiceImpl implements EModelService {

  public <T> List<T> findElements(Class<T> clazz, List<String> tagsToMatch) {
    return null;
  }
}

4. Use Ctrl+1 to ask JDT to add the unimplemented methods.
5. Now I have three methods.

import java.util.List;
public class ModelServiceImpl implements EModelService {
  public <T> List<T> findElements(Class<T> clazz, List<String> tagsToMatch) {
    return null;
  }

  public <T> List<T> findElements(Class<T> clazz, List<String> tagsToMatch) {
    // TODO Auto-generated method stub
    return null;
  }

  public <T> List<T> findPerspectiveElements(Class<T> clazz,
      List<String> tagsToMatch) {
    // TODO Auto-generated method stub
    return null;
  }
}
Comment 1 Dani Megert CLA 2010-11-15 10:02:16 EST
Markus, this looks like a bug in org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2.getUnimplementedMethods(ITypeBinding, boolean).
Comment 2 Markus Keller CLA 2010-11-25 13:23:11 EST
Created attachment 183874 [details]
Fix

Yeah, it's one of those hairy areas where we have to play type rules and we don't have enough APIs from the compiler...
Comment 3 Markus Keller CLA 2010-11-25 13:36:17 EST
Fixed in HEAD.

Thanks for the small snippets, Remy! I stole them for the regression test.