Bug 17171 Quickfix: no proposal for wrong inst var initialization
- create the following code: public class Test { int fFoo= 1.2; } - a Quickfix bulb and a wiggly line appears for fFoo. However, pressing Cntr-1 does not show any proposals but the .log contains: java.lang.ClassCastException: org.eclipse.jdt.core.dom.FieldDeclaration at org.eclipse.jdt.internal.ui.text.correction.LocalCorrectionsSubProcessor.addCast Proposals(LocalCorrectionsSubProcessor.java:90) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorre ctions(JavaCorrectionProcessor.java:193) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.computeCompl etionProposals(JavaCorrectionProcessor.java:127) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals (ContentAssistant.java:1205) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals (CompletionProposalPopup.java:104) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$3 (CompletionProposalPopup.java:103) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run (CompletionProposalPopup.java:72) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals (CompletionProposalPopup.java:67) at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions (ContentAssistant.java:1140) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionSourceViewer.doOperati on(JavaCorrectionSourceViewer.java:47) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer .doOperation(CompilationUnitEditor.java:217) at org.eclipse.ui.texteditor.TextOperationAction.run (TextOperationAction.java:88) at org.eclipse.ui.texteditor.RetargetTextEditorAction.run (RetargetTextEditorAction.java:127) at org.eclipse.jface.action.Action.runWithEvent(Action.java:590) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1527) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1289) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1085) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:200) at org.eclipse.core.launcher.Main.run(Main.java:643) at org.eclipse.core.launcher.Main.main(Main.java:476)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java
res[0]= null;
				
				decl.accept(new GenericVisitor() {
					public boolean visit(ReturnStatement node) {
						if (res[0] == null) {
							Expression expr= node.getExpression();
							if (expr != null) {
								ITypeBinding binding= expr.resolveTypeBinding();
								if (binding != null) {
									res[0]= binding;
								} else {
									res[0]= node.getAST().resolveWellKnownType("java.lang.Object"); 
								}
							} else {
								res[0]= node.getAST().resolveWellKnownType("void"); 
							}
						}
						return false;
					}
				});
				ITypeBinding type= res[0];
				if (type == null) {
					type= decl.getAST().resolveWellKnownType("void"); 
				} 
				
				String str= type.getName() + " "; 
				int pos= ((MethodDeclaration) decl).getName().getStartPosition();
				
				String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.missingreturntype.description", type.getName()); 
				InsertCorrectionProposal proposal= new InsertCorrectionProposal(label, cu, pos, str, 1);