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
} else if (op == InfixExpression.Operator.LEFT_SHIFT || op == InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED || op == InfixExpression.Operator.RIGHT_SHIFT_SIGNED) {
				
				return infix.getAST().resolveWellKnownType("int"); 
			}
			if (node.equals(infix.getLeftOperand())) {
				
				ITypeBinding rigthHandBinding= infix.getRightOperand().resolveTypeBinding();
				if (rigthHandBinding != null) {
					return rigthHandBinding;
				}
			} else {
				
				ITypeBinding leftHandBinding= infix.getLeftOperand().resolveTypeBinding();
				if (leftHandBinding != null) {
					return leftHandBinding;
				}
			}
			if (op != InfixExpression.Operator.EQUALS && op != InfixExpression.Operator.NOT_EQUALS) {
				return infix.getAST().resolveWellKnownType("int"); 
			}
			break;
		case ASTNode.INSTANCEOF_EXPRESSION:
			InstanceofExpression instanceofExpression= (InstanceofExpression) parent;
			return instanceofExpression.getRightOperand().resolveBinding();
		case ASTNode.VARIABLE_DECLARATION_FRAGMENT:
			VariableDeclarationFragment frag= (VariableDeclarationFragment) parent;
			if (frag.getInitializer().equals(node)) {
				return frag.getName().resolveTypeBinding();
			}
			break;