Bug 180713

Summary: Anonymous type rendered as number in hover
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, martinae
Version: 3.3Keywords: polish
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Offending hover
none
Proposed fix and regression tests
none
Small adjustement on top of previous patch none

Description Philipe Mulet CLA 2007-04-03 09:49:33 EDT
Build 3.3M6

Hovering on top of #toArray(...) message sending in following code reveals poor handling of anonymous types: "<141> 141[] X.toArray(141 t)"

public class X {
	static <T> T[] toArray(T t) { return null; }
	public static void main(String[] args) {
		System.out.println(toArray(new Object(){}));
	}
}
Comment 1 Philipe Mulet CLA 2007-04-03 10:05:24 EDT
Created attachment 62776 [details]
Offending hover
Comment 2 Martin Aeschlimann CLA 2007-04-16 13:14:25 EDT
- Is this fixable on the JDT/UI side? We get the resolved label that contains these number as types
- Is this corner case?
Comment 3 Philipe Mulet CLA 2007-04-16 22:13:24 EDT
I think it should rather be addressed by information in the binding key itself (i.e. instead of a number, it should remember the supertype S, so as to be able to render: new S(){}).
Comment 4 Martin Aeschlimann CLA 2007-04-17 06:18:21 EDT
JDT.Core should probably still return a valid type name.
I suggest to return something like $1, what makes it clear that this is an anonymous type.
Or maybe 'Anonym_Object'.

I don't think this is a common scenario, and opt for a simple solution.
Comment 5 Philipe Mulet CLA 2007-04-17 09:10:10 EDT
Interesting thought... I was leaning to us being consistent with our error messages.
e.g.
public class X {
        static <T> T[] toArray(T t) { return null; }
        public static void main(String[] args) {
                int i = toArray(new Object(){});
        }
}

cannot convert from new Object(){}[] to int
Comment 6 Jerome Lanneluc CLA 2007-04-26 11:23:53 EDT
Created attachment 65052 [details]
Proposed fix and regression tests
Comment 7 Jerome Lanneluc CLA 2007-04-26 12:33:29 EDT
Fix and tests released for 3.3M7 in HEAD.
Comment 8 Jerome Lanneluc CLA 2007-04-27 06:16:47 EDT
Created attachment 65184 [details]
Small adjustement on top of previous patch

This fixes the case where the type signature is included in another signature (e.g. a method signature).

Will be in build > I20070427-0010
Comment 9 Eric Jodet CLA 2007-04-27 06:34:15 EDT
Verified for 3.3 M7 using build I20070427-0010
Comment 10 Jerome Lanneluc CLA 2007-06-21 11:23:31 EDT
*** Bug 99627 has been marked as a duplicate of this bug. ***