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

Bug 355505

Summary: ClassCastException when generating an array access
Product: z_Archived Reporter: Brian Svihovec <svihovec>
Component: EDTAssignee: Project Inbox <edt.javascriptgen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: greer
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Simle ArrayAccess testcase. none

Description Brian Svihovec CLA 2011-08-23 09:52:56 EDT
Create a package named pack1 and import the attached EGL file.  When the file is run with the JS Generator, a ClassCastException is thrown on the array access.  

I believe the fix is to change ArrayAccessTemplate::genExpression to the following, but I am not positive:

public void genExpression(ArrayAccess expr, Context ctx, TabbedWriter out) {
		Field field = null;
		if(expr.getArray() instanceof Name){
			if (((Name) expr.getArray()).getNamedElement() instanceof Field)
				field = (Field) ((Name) expr.getArray()).getNamedElement();
		}
		if (field != null && field.getContainer() != null && field.getContainer() instanceof Type)
				ctx.invoke(genContainerBasedArrayAccess, (Type) field.getContainer(), ctx, out, expr, field);
		else
			genArrayAccess(expr, ctx, out);
	}
Comment 1 Brian Svihovec CLA 2011-08-23 09:53:40 EDT
Created attachment 202001 [details]
Simle ArrayAccess testcase.
Comment 2 Scott Greer CLA 2011-08-26 12:26:08 EDT
Brian,

Verified the fix you provided and committed it.
Comment 3 Lisa Lasher CLA 2011-10-11 16:13:46 EDT
Closing this defect.