Bug 180713 - Anonymous type rendered as number in hover
Summary: Anonymous type rendered as number in hover
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
: 99627 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-04-03 09:49 EDT by Philipe Mulet CLA
Modified: 2007-06-21 11:23 EDT (History)
2 users (show)

See Also:


Attachments
Offending hover (31.22 KB, image/jpeg)
2007-04-03 10:05 EDT, Philipe Mulet CLA
no flags Details
Proposed fix and regression tests (2.90 KB, patch)
2007-04-26 11:23 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Small adjustement on top of previous patch (851 bytes, patch)
2007-04-27 06:16 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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. ***