Bug 80996 [Quick Fix] Incorrect return type of created method
Eclipse Version: 3.1.0 Build id: 200412081200 Place the following code in Eclipse - The class name is QuickFixEquals. package eclipse.bug; import java.util.List; public class QuickFixEquals { public boolean hasChildren() { if(getContentSpec().equals("Test")) return true; return false; } } Note that the code is importing java.util.List This would give a compilation error with a quick fix option. On applying QuickFix the following code is generated: private List getContentSpec() { // TODO Auto-generated method stub return null; } I would expect the return type to be Object - but it turned out to be List! [If you remove the import statement, it correctly sets the return type of getContentSpec to Object.] If the original class was import java.util.ArrayList; import java.util.List; public class QuickFixEquals { public boolean hasChildren() { if(getContentSpec().equals("Test")) return true; return false; } public List<String> getList() { return new ArrayList<String>(); } } The QuickFix creates the following method - private AbstractList<E> getContentSpec() { // TODO Auto-generated method stub return null; }
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java
parent= parent.getParent();
		}
		switch (parent.getNodeType()) {
			case ASTNode.TYPE_DECLARATION:
				if (node.getLocationInParent() == TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY) {
					kind= SimilarElementsRequestor.INTERFACES;
				} else if (node.getLocationInParent() == TypeDeclaration.SUPERCLASS_TYPE_PROPERTY) {
					kind= SimilarElementsRequestor.CLASSES;
				}
				break;
			case ASTNode.ENUM_DECLARATION:
				kind= SimilarElementsRequestor.INTERFACES;
				break;
			case ASTNode.METHOD_DECLARATION:
				if (node.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY) {
					kind= SimilarElementsRequestor.CLASSES;
				} else if (node.getLocationInParent() == MethodDeclaration.RETURN_TYPE2_PROPERTY) {
					kind= SimilarElementsRequestor.ALL_TYPES | SimilarElementsRequestor.VOIDTYPE;
				}
				break;
			case ASTNode.INSTANCEOF_EXPRESSION:
				kind= SimilarElementsRequestor.REF_TYPES  & ~SimilarElementsRequestor.VARIABLES;
				break;
			case ASTNode.THROW_STATEMENT:
				kind= SimilarElementsRequestor.CLASSES;
				break;
			case ASTNode.CLASS_INSTANCE_CREATION:
				if (((ClassInstanceCreation) parent).getAnonymousClassDeclaration() == null) {
					kind= SimilarElementsRequestor.CLASSES;
				} else {