Bug 364521 - [quick fix] Suggest typed return values in quick fix
Summary: [quick fix] Suggest typed return values in quick fix
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 16:29 EST by Remy Suen CLA
Modified: 2011-11-23 07:11 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.