Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355505 - ClassCastException when generating an array access
Summary: ClassCastException when generating an array access
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-23 09:52 EDT by Brian Svihovec CLA
Modified: 2017-02-23 14:16 EST (History)
1 user (show)

See Also:


Attachments
Simle ArrayAccess testcase. (318 bytes, application/octet-stream)
2011-08-23 09:53 EDT, Brian Svihovec CLA
no flags Details

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