Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330241 - [quick fix] 'Add unimplemented methods' adds two methods from its implementing interface when one is already there
Summary: [quick fix] 'Add unimplemented methods' adds two methods from its implementin...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-15 08:43 EST by Remy Suen CLA
Modified: 2010-11-25 13:36 EST (History)
1 user (show)

See Also:


Attachments
Fix (5.21 KB, patch)
2010-11-25 13:23 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.