Bug 575008 - Clean-up "Use diamond operator" does not consider method arguments
Summary: Clean-up "Use diamond operator" does not consider method arguments
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.21   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-23 14:08 EDT by Hannes Wellmann CLA
Modified: 2024-05-02 15:04 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hannes Wellmann CLA 2021-07-23 14:08:16 EDT
JDT's clean up "Use diamond operator" does not consider constructor calls used immediately as method arguments, like the following:

"""
public void foo() {
	bar(new HashMap<String, String>());
}

public void bar(Map<String, String> map) {}
"""

The generic type arguments of the Hashmap are not removed, even tough

bar(new HashMap<>());

is perfectly valid.
Comment 1 Jeff Johnston CLA 2021-07-23 14:55:39 EDT
Moving to jdt.core as the jdt.ui cleanup operates on code flagged with problem ids.  In this case, setting the Java -> Compiler -> Errors/Warnings -> Generic Types -> Redundant Type Arguments to Warning or Error does not flag the call to bar.
Comment 2 Eclipse Genie CLA 2024-05-02 15:04:48 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.