Bug 81980 Unexpected unresolved enum quick fix suggestions [quick fix] [5.0]
Although the create field and create constant in my enum type suggestions for the quick fix in the code listed below compiles and works fine. It is not quite what I expected for the use of enumerated types. public class EnumQuickFixBug implements Runnable { private State state; private enum State {begin, end}; public void run() { state = State.begin; // Try quick fixing the line below state = State.middle; state = State.end; } public static void main(String args[]) { EnumQuickFixBug bugs = new EnumQuickFixBug(); bugs.run(); System.out.println("Done"); } } I expected to declaration of the enum type to change to something like: private enum State {begin, end, middle}; but instead it did something like this: private enum State {begin, end; public static State middle;};
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
ITypeBinding guessedType= ASTResolving.guessBindingForReference(node);
			ITypeBinding objectBinding= astRoot.getAST().resolveWellKnownType("java.lang.Object"); 
			String identifier= node.getIdentifier();
			boolean isInStaticContext= ASTResolving.isInStaticContext(node);
			
			loop: for (int i= 0; i < varsAndMethodsInScope.length; i++) {
				IBinding varOrMeth= varsAndMethodsInScope[i];
				if (varOrMeth instanceof IVariableBinding) {
					IVariableBinding curr= (IVariableBinding) varOrMeth;
					String currName= curr.getName();
					if (currName.equals(otherNameInAssign)) {
						continue loop;
					}
					boolean isFinal= Modifier.isFinal(curr.getModifiers());
					if (isFinal && curr.isField() && isWriteAccess) {
						continue loop;
					}
					if (isInStaticContext && !Modifier.isStatic(curr.getModifiers())) {
						continue loop;
					}
					
					int relevance= 0;
					if (NameMatcher.isSimilarName(currName, identifier)) {
						relevance += 3; 
					}
					if (currName.equalsIgnoreCase(identifier)) {
						relevance+= 5;
					}
					ITypeBinding varType= curr.getType();
					if (varType != null) {