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

Bug 113052

Summary: [generate constructor] generate constructor using fields incorrectly adds imports [code generation]
Product: [Eclipse Project] JDT Reporter: Philip Mayer <eclipsetalk2>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Philip Mayer CLA 2005-10-19 05:10:08 EDT
Suppose you have a class A in a package p with two fields; the first typed with
q.B (qualified), and the second with B from package p (unqualified):

----
package p;

public class A {
	q.B field1;
	B field2;
}
----

Generate Constructor using fields adds an import for q.B, leading to the
following code with compile errors:

----
package p;

import q.B;

public class A {
	q.B field1;
	B field2;
	/**
	 * @param field1
	 * @param field2
	 */
	public A(B field1, p.B field2) {
		super();
		// TODO Auto-generated constructor stub
		this.field1 = field1;
		this.field2 = field2;
	}
}
----

field2 is now typed with "q.B", and the assignment fails.
Comment 1 Dani Megert CLA 2010-01-29 03:20:12 EST
Still an issue in I20100128-1731.
Comment 2 Eclipse Genie CLA 2020-04-18 07:35:12 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. 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.