Bug 24747

Summary: incorrect compile error message
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 2.0   
Target Milestone: 2.1 M3   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Adam Kiezun CLA 2002-10-14 09:50:54 EDT
class A {
    NonExistent[] f(){}
}

the message says '[] cannot be resolved (or is not a valid return type) for the 
method f'

(the type name is not mentioned)
Comment 1 Olivier Thomann CLA 2002-10-15 14:16:41 EDT
This is a bug in the shortReadableName() method.
Comment 2 Olivier Thomann CLA 2002-10-15 14:50:29 EDT
Proposal:
1) remove shortReadableName() on
org.eclipse.jdt.internal.compiler.lookup.TypeBinding
2) Add:
public char[] shortReadableName(){
	char[] brackets = new char[dimensions * 2];
	for (int i = dimensions * 2 - 1; i >= 0; i -= 2) {
		brackets[i] = ']';
		brackets[i - 1] = '[';
	}
	return CharOperation.concat(leafComponentType.shortReadableName(), brackets);
}
on org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
3) Add:
public char[] shortReadableName(){
	return simpleName;
}
on org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding.
Comment 3 Olivier Thomann CLA 2002-10-15 14:55:43 EDT
The bug was simply that the method on TypeBinding was incorrectly calling
sourceName() and therefore the problemReferenceBinding method was never called.
It called sourceName() for the problemReferenceBinding instead which returns null.
Philippe - Could you please verify the proposal?
Comment 4 Olivier Thomann CLA 2002-10-17 16:41:48 EDT
Fixed and released in 2.1 stream.
Comment 5 David Audel CLA 2002-11-13 06:19:29 EST
Verified.