Bug 376766 - [quick fix] Quick fixes on Type Mismatch don't work well in enhanced for loop
Summary: [quick fix] Quick fixes on Type Mismatch don't work well in enhanced for loop
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-13 14:04 EDT by Markus Keller CLA
Modified: 2018-12-21 04:23 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2012-04-13 14:04:32 EDT
package xy;

import java.util.Collection;
import java.util.List;

public class Try {
    void foo(Object[] array, List list, Collection<Object> coll) {
        for (String string : array) {
        }
        for (String string : list) {
        }
        for (String string : coll) {
        }
    }
}

For each "Type mismatch: cannot convert from element type Object to String" error, there should be a quick fix (with high relevance):
- Change type of 'string' to 'Object'

If applicable, also offer this quick fix:
- Change type of 'array/list/coll' to 'String[]/List<String>/Collection<String>'

The first two cases should also offer:
- Add cast to 'String[]'/'List<String>'
Comment 1 Eclipse Genie CLA 2018-12-20 13:42:19 EST
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.
Comment 2 Dani Megert CLA 2018-12-21 04:23:01 EST
(In reply to Markus Keller from comment #0)
> For each "Type mismatch: cannot convert from element type Object to String"
> error, there should be a quick fix (with high relevance):
> - Change type of 'string' to 'Object'

This one now exists.


Still missing:

> If applicable, also offer this quick fix:
> - Change type of 'array/list/coll' to
> 'String[]/List<String>/Collection<String>'
> 
> The first two cases should also offer:
> - Add cast to 'String[]'/'List<String>'