Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 482793

Summary: [null] CoreException using a quick fix on method overriding with unconstrained type parameter
Product: [Eclipse Project] JDT Reporter: Marc-AndrĂ© Laperle <malaperle>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: alexmonthy
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows NT   
Whiteboard: stalebug

Description Marc-André Laperle CLA 2015-11-22 15:34:56 EST
Using Eclipse 4.6-I20151117-0800

I have some code that looks like this:

class Foo<E> implements Collection<E> {
...

@Override
  public @Nullable <T> T @Nullable [] toArray(T[] a) { // Illegal redefinition of parameter a, inherited method from Collection<E> does not constrain this parameter


The quick fix available for this is "Change parameter 'a' to @Nullable". This already seems odd, because the quick fix should either be about unconstraining 'a' (with @NonNullByDefault for example) or constraining the parent method. Once the quick fix is used, the method now looks like this

public @Nullable <T> T @Nullable [] toArray(@Nullable T[] a) { // Illegal redefinition of parameter a, inherited method from Collection<E> does not constrain this parameter

The quick fix is available again, but this time, it generates this exception:

org.eclipse.core.runtime.CoreException: The fix 'Change parameter 'a' to '@Nullable'' generated a null change.
	at org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix.createChange(CompilationUnitRewriteOperationsFix.java:101)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.createTextChange(FixCorrectionProposal.java:147)
	at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.createChange(CUCorrectionProposal.java:238)
	at org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal.getChange(ChangeCorrectionProposal.java:383)
	at org.eclipse.jdt.ui.text.java.correction.ChangeCorrectionProposal.performChange(ChangeCorrectionProposal.java:138)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.LinkedCorrectionProposal.performChange(LinkedCorrectionProposal.java:148)
	at org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal.apply(CUCorrectionProposal.java:181)
	at org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposal.apply(FixCorrectionProposal.java:177)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:963)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:914)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$27(CompletionProposalPopup.java:910)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$5.widgetDefaultSelected(CompletionProposalPopup.java:674)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:119)
Comment 1 Eclipse Genie CLA 2019-04-01 01:24:13 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.