Bug 460511 - [quick fix] Diamond operator prevents suggesting the creation of a new constructor
Summary: [quick fix] Diamond operator prevents suggesting the creation of a new constr...
Status: REOPENED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-21 11:07 EST by Lukas Eder CLA
Modified: 2024-03-27 20:42 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Eder CLA 2015-02-21 11:07:59 EST
Consider the following program

------------------------------------------------------
class Tuple2<T1, T2> {
    static <T1, T2> Tuple2<T1, T2> tuple(T1 t1, T2 t2) {
        return new Tuple2<>(t1, t2);
    }
}
------------------------------------------------------

I haven't written the constructor yet, but I'd like to have Eclipse generate it for me using quick fix. But it doesn't work - there is only an error message "Cannot infer type arguments for Tuple2<>".

A workaround would be to explicitly set the generic type arguments prior to invoking quick fix:

------------------------------------------------------
class Tuple2<T1, T2> {
    static <T1, T2> Tuple2<T1, T2> tuple(T1 t1, T2 t2) {
        return new Tuple2<T1, T2>(t1, t2);
    }
}
------------------------------------------------------
Comment 1 Lukas Eder CLA 2015-02-21 11:08:14 EST
I'm using 4.5.0 M5, btw.
Comment 2 Eclipse Genie CLA 2018-09-17 14:50:54 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.
Comment 3 Lukas Eder CLA 2020-03-20 11:38:16 EDT
With Eclipse 4.15.0, things got worse. I'm now no longer offered any quick fixes on the wrong code!

When I remove the diamond operator...

------------------------------------------------------
class Tuple2<T1, T2> {
    static <T1, T2> Tuple2<T1, T2> tuple(T1 t1, T2 t2) {
        return new Tuple2(t1, t2);
    }
}
------------------------------------------------------

I now get quick fix options, including the desired one to generate the constructor:

------------------------------------------------------
class Tuple2<T1, T2> {
    public Tuple2(T1 t1, T2 t2) {
        // TODO Auto-generated constructor stub
    }

    static <T1, T2> Tuple2<T1, T2> tuple(T1 t1, T2 t2) {
        return new Tuple2(t1, t2);
    }
}
------------------------------------------------------

But now, with the removed diamond operator, I'm getting a rawtype warning, obviously. So I have to re-add the diamond operator.
Comment 4 Eclipse Genie CLA 2022-03-13 16:13:47 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.
Comment 5 Eclipse Genie CLA 2024-03-27 20:42:03 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.