Bug 575008

Summary: Clean-up "Use diamond operator" does not consider method arguments
Product: [Eclipse Project] JDT Reporter: Hannes Wellmann <wellmann.hannes1>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, jjohnstn, kalyan_prasad, sravankumarl
Version: 4.21   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

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.