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

Bug 325199

Summary: A reference in an instance of http://www.eclipse.org/emf/2002/GenModel is wrongly seen as having a null type.
Product: [Modeling] Acceleo Reporter: Romain Guider <romain.guider>
Component: CoreAssignee: Project Inbox <acceleo-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: stephane.begaudeau
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Acceleo template that illustrates the bug and allows reproducing it none

Description Romain Guider CLA 2010-09-14 03:24:08 EDT
Build Identifier: 20100617-1415

In the following template 
[template public generateBad(genModel : GenModel)]
	[genModel.genPackages.ecorePackage.name->first()/]
[/template]

the ecorePackage reference is seen as having a null type and nothing can be done with it. Executing the template results in the following output :
	org.eclipse.emf.ecore.impl.DynamicEObjectImpl@161d10f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@e441ee (name: OclInvalid_Class) (instanceClassName: null) (abstract: false, interface: false))

While executing the same  template with this text instead
	[genModel.genPackages.ecorePackage->first()/]
outputs the expected result : 

org.eclipse.emf.ecore.impl.EPackageImpl@420177 (name: kparser) (nsURI: http://www.obeo.fr/knowledge/kparser/v1.0, nsPrefix: kparser)


There's a work around however. Use a query to get the first package and call the query just like it is done in the generateGood template in the attached example.



Reproducible: Always

Steps to Reproduce:
1.put the template attached to this bug in an Acceleo project
2.run the generation
3.open up the result.
Comment 1 Romain Guider CLA 2010-09-14 03:26:13 EDT
Created attachment 178792 [details]
Acceleo template that illustrates the bug and allows reproducing it
Comment 2 Stephane Begaudeau CLA 2011-03-23 06:51:43 EDT
if "[genModel.genPackages.ecorePackage->first()/]" generate the same thing for me:
"org.eclipse.emf.ecore.impl.EPackageImpl@7be2149c (name: scala) (nsURI: http://github.com/sbegaudeau/acceleo/scalametamodel/2011/01, nsPrefix: scala)"

And "[genModel.genPackages.ecorePackage.name->first()/]" generate what I am expecting: "scala".

I tried both ways: 
- [genModel.genPackages.ecorePackage.name->first()/]
and
- [getFirstPackage(genModel).name/]
- [query public getFirstPackage(genModel : GenModel) : EPackage = genModel.genPackages.ecorePackage->first()/]

And the result is the same. since both are doing the same thing. Are you sure, that you did not change your metamodel between the execution ? Since your metamodel seems to have a valid name "kparser", I don't see why this:
"[genModel.genPackages.ecorePackage.name->first()/]" would not work expect in a query.

I'll close this bug for now, if you can reproduce it reopen it.