Community
Participate
Working Groups
class A { public static int foo() { return null; } } -> Quick Fix on 'return null'; java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.PrimitiveType.setPrimitiveTypeCode(PrimitiveType.java:219) at org.eclipse.jdt.core.dom.AST.newPrimitiveType(AST.java:775) at org.eclipse.jdt.internal.ui.text.correction.ASTResolving.getTypeFromTypeBinding(ASTResolving.java:433) at org.eclipse.jdt.internal.ui.text.correction.LocalCorrectionsSubProcessor.addCastProposals(LocalCorrectionsSubProcessor.java:92) at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:149) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:205) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.processProblemAnnotations(JavaCorrectionProcessor.java:173) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.computeCompletionProposals(JavaCorrectionProcessor.java:136) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1281) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:178) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$7(CompletionProposalPopup.java:177) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$3.run(CompletionProposalPopup.java:139) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:65) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:134) at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1201) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant.showPossibleCompletions(JavaCorrectionAssistant.java:153) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:153) at org.eclipse.jdt.internal.ui.javaeditor.JavaSelectMarkerRulerAction.run(JavaSelectMarkerRulerAction.java:52) at org.eclipse.ui.texteditor.AbstractRulerActionDelegate.run(AbstractRulerActionDelegate.java:98) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:250) at org.eclipse.ui.internal.PluginAction.run(PluginAction.java:212) at org.eclipse.ui.texteditor.AbstractTextEditor$4.triggerAction(AbstractTextEditor.java:1674) at org.eclipse.ui.texteditor.AbstractTextEditor$4.mouseUp(AbstractTextEditor.java:1681) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:130) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:836) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1775) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1483) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1271) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1254) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539)
Problem is that the type biniding for a null binding returns true on 'isPrimitive' for the given code eample, set break point in ASTResolving.getTypeFromTypeBinding(AST, ITypeBinding) line: 432
I will investigate.
I fixed it, but in self-hosting workspace now I get: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: assertion failed; Tries to replace with null (use remove instead) at org.eclipse.jdt.internal.corext.Assert.isTrue(Assert.java:130) at org.eclipse.jdt.internal.corext.dom.ASTRewrite.markAsReplaced(ASTRewrite.java:192) at org.eclipse.jdt.internal.corext.dom.ASTRewrite.markAsReplaced(ASTRewrite.java:210) at org.eclipse.jdt.internal.ui.text.correction.LocalCorrectionsSubProcessor.addCastProposals(LocalCorrectionsSubProcessor.java:94) at org.eclipse.jdt.internal.ui.text.correction.QuickFixProcessor.process(QuickFixProcessor.java:151) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:205) at org.eclipse.jdt.internal.ui.text.correction.CorrectionMarkerResolutionGenerator.getResolutions(CorrectionMarkerResolutionGenerator.java:119) at org.eclipse.ui.internal.registry.MarkerHelpRegistry.getResolutions(MarkerHelpRegistry.java:181) at org.eclipse.ui.views.tasklist.ResolveMarkerAction.getResolutions(ResolveMarkerAction.java:86) at org.eclipse.ui.views.tasklist.ResolveMarkerAction.run(ResolveMarkerAction.java:62) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent(ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0(ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent(ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:836) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1775) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1483) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1271) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1254) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:247) at org.eclipse.core.launcher.Main.run(Main.java:703) at org.eclipse.core.launcher.Main.main(Main.java:539) Is this a known problem? Now if typeBinding is the type binding for null, we have: typeBinding.isPrimitive(): false typeBinding.isNullType(): true I think these are the expected answers. So there is something else wrong in the quick fix code. This fix is released in 2.1 head contents of jdt.core. Please take this code and let me know if it works for you. I used the latest jdt.ui head contents to try my fix with your test case.
Now we have: isPrimitive() => false isNullType() => true Fixed and released in 2.1 stream. Regression test added. See bug 33683 for the second stack trace.
Verified.