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

Bug 364521

Summary: [quick fix] Suggest typed return values in quick fix
Product: [Eclipse Project] JDT Reporter: Remy Suen <remy.suen>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P4 CC: amj87.iitr, deepakazad, njdoyle
Version: 3.8   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Remy Suen CLA 2011-11-22 16:29:28 EST
I20111116-0810

public class GenericsSuggestionBug {
  Set<String> v(Set<String> o) {
//  return o == null ? Collections .<String>emptySet() : o;
    return o == null ? Collections .emptySet() : o;
  }
}

The code at the top will compile but the one in the bottom doesn't. Can a quick fix be added for the top case? Is the compiler capable of diagnosing this case?

Thanks.
Comment 1 Ayushman Jain CLA 2011-11-23 01:06:46 EST
(In reply to comment #0)
> Can a quick
> fix be added for the top case?

Quick fix for the top case? But that compiles fine, no? Why is a quick fix needed? For the bottom case I already see a valid quick fix. Did you mean quick assist?
Comment 2 Ayushman Jain CLA 2011-11-23 01:09:10 EST
(In reply to comment #1)
> Quick fix for the top case? But that compiles fine, no? Why is a quick fix
> needed? For the bottom case I already see a valid quick fix. Did you mean quick
> assist?

I guess you meant a quick fix for the bottom case that will turn it into the one on the top. Moving to JDT/UI.
Comment 3 Deepak Azad CLA 2011-11-23 02:26:52 EST
A case of conditional and generics not mixing well...

I guess we can offer 'Add type parameters to method invocation in then clause' (or something like that) quick fix here.
Comment 4 Remy Suen CLA 2011-11-23 07:11:54 EST
(In reply to comment #2)
> (In reply to comment #1)
> > Quick fix for the top case? But that compiles fine, no? Why is a quick fix
> > needed? For the bottom case I already see a valid quick fix. Did you mean quick
> > assist?
> 
> I guess you meant a quick fix for the bottom case that will turn it into the
> one on the top.

Yes, that's what I meant.