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

Bug 361601

Summary: [quick fix] "Cast argument" does not suggest all fix-worthy types
Product: [Eclipse Project] JDT Reporter: Paul Benedict <pbenedict>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: ankur_sharma, deepakazad
Version: 3.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Paul Benedict CLA 2011-10-20 22:13:16 EDT
Build Identifier: 20110916-0149

interface Message {}

class MimeMessage implements Message {}

class SimpleMessage implements Message {}

class MailSender {
    void send(MimeMessage msg) {}
    void send(SimpleMessage msg) {}
}

public class Test {

    public static void main(String... args) {
        MailSender sender = new MailSender();
        Message msg = new SimpleMessage();
        sender.send(msg);
    }
}

ctrl+1 on 'send' of 'sender.send'; the only cast suggested for 'msg' is MimeMessage, but SimpleMessage should also be suggested. This makes it look like there is only one typecast that can correct the problem.

Reproducible: Always

Steps to Reproduce:
1. See code above.
2. Press ctrl+1 at error
3. See proposal
Comment 1 Deepak Azad CLA 2011-10-21 01:12:20 EDT
Even though there is an error, the method is resolved by JDT/Core to one of the two options and in the quick fix code we never check if there are overloaded methods.

If we change something here, we would also have to look at other quick fixes created by UnresolvedElementsSubProcessor.doEqualNumberOfParameters(...).
Comment 2 Deepak Azad CLA 2011-10-24 19:56:33 EDT
*** Bug 355534 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2020-01-16 19:20:49 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.