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

Bug 361187

Summary: Annotation records with fields initialized to Enumeration values produce invalid annotation objects
Product: z_Archived Reporter: Paul Harmon <pharmon>
Component: EDTAssignee: Project Inbox <edt.mofmodel-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jvincens, svihovec, tww
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Paul Harmon CLA 2011-10-17 16:45:56 EDT
For the given annotion/enum definitions:

Enumeration TestEnum
	Fred,
	Wilma,
	Barney
end

record TestAnn type annotation {
	targets=[FieldMbr]
}

	fredField TestEnum = TestEnum.Fred;
	wilmaField TestEnum = TestEnum.Wilma;
	intField int = 3;
	strField string = "string";

end

record TestAnn2 type annotation {
	targets=[FieldMbr]
}

	value TestEnum?;

end


Define the following Library:

library lib1

	field1 int {@TestAnn{intField = 55555}};
	field2 int {@TestAnn{fredField = TestEnum.Barney}};
	field3 int {@TestAnn{wilmaField = Barney}};
	
	field4 int {testann2 = fred};
	field5 int {@testann2{wilma}};

end



If you look at the IR generated, all of the references to the enumerations are MemberAccess, except the one for fiel4. This annotation's value field is set to the string "Fred". The IR value for this field is actually the EnumerationEntry.
Because of this, any users of the Lib1 IR would need to check for 2 different types of annotation values.

This needs to be changed to be consistant. The value of an annotion field with an Enumeration should always be the EnumerationEnty for this scenerio.
Comment 1 Paul Harmon CLA 2011-11-07 14:07:35 EST
This has been fixed. Initial values of annotation fields, when initialized to an enumeration or array of enumerations will contain the expressions. When the annotation is instantiated, the initialization code for the Annotation will convert these initial values from an expression and resolve the actual enumeration value (EnumerationEntry) based on the type of the annotation field.
Comment 2 Paul Harmon CLA 2011-11-18 09:22:52 EST
excellent