Bug 276890

Summary: [content assist] proposes nothing for generic type with non-trivial constructor
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: David Audel <david_audel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Olivier_Thomann
Version: 3.5Flags: Olivier_Thomann: review+
kent_johnson: review+
Target Milestone: 3.5 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Markus Keller CLA 2009-05-19 09:41:15 EDT
I20090518-2000

Constructor completion does not work for constructor with parameter in generic type from another package

To reproduce, invoke content assist after 'new Stu'. I only get a proposal for the no-arg constructor. Same problem if class Stuff is abstract.

Works fine if a.Stuff is already imported or is in the same package.


//---------

package p;

public class C {
	public static void main(String[] args) {
		new Stu
	}
}

//---------

package a;

import java.util.List;

public class Stuff<E> {
	public Stuff(E e) {}
//	public Stuff(Object o) {}
//	public Stuff(List<E> ees) {}
//	public Stuff() {} // only this one works
}
Comment 1 Dani Megert CLA 2009-05-19 09:46:43 EDT
Nothing coming back from completion engine.
Comment 2 David Audel CLA 2009-05-20 09:18:56 EDT
Created attachment 136486 [details]
Proposed patch

When the constructor has parameters, CompletionEngine#getResolvedSignature() computes the binding of the declaring type from the type name.
If the type is generic then a RawTypeBinding is computed and getResolvedSignature() assumed that this binding was a SourceTypeBinding.
The erasure of the computed binding must be used instead.
Comment 3 David Audel CLA 2009-05-20 09:51:17 EDT
Olivier, could review the patch ?
Comment 4 David Audel CLA 2009-05-20 09:54:59 EDT
Kent, could you review the patch ?
Comment 5 Olivier Thomann CLA 2009-05-20 10:24:38 EDT
+1. Patch looks good.
Comment 6 David Audel CLA 2009-05-20 10:43:31 EDT
Released for 3.5RC2.

Tests added
  CompletionTests2#testBug276890_01() -> testBug276890_03()
Comment 7 Dani Megert CLA 2009-05-21 04:54:57 EDT
Verified in I20090520-2000.