spurious type conflicts when importing two related packages in an Xtext grammar [message #1405931] |
Fri, 08 August 2014 14:32 |
Rafael Chaves Messages: 23 Registered: April 2012 |
Junior Member |
|
|
I have two xcore files and a dependency between them:
a.xcore
b.xcore -> a.xcore
a.xcore defines a class ClassInA. b.xcore defines a ClassInB which has a reference myA to a.ClassInA.
Since I wanted to import them in my Xtext grammar, I created a genmodel/ecore for each, and registered each generated package/genmodel in the MWE workflow.
However, in my grammar (which imports both "a" and "b"), in the rule for ClassInB, which includes a reference to ClassInA, like this:
ClassInB:
'B' myA=[ClassInA];
I get an error like this:
Cannot find compatible feature myA in sealed EClass ClassInB from imported package b: The existing reference 'myA' has an incompatible type 'ClassInA'. The expected type is 'ClassInA'.
I debugged this a bit and it turns out the cause is that there are multiple definitions of ClassInA (akin to a ClassCastException when the same class is loaded by two classloaders), causing the type clash. I guess the reason is that each imported Xcore/ECore model gets its own copy of the model elements, including those obtaining via cross-package references, instead of sharing them.
Is this a bug or a mistake on my part? Any workarounds?
Thanks.
[Updated on: Fri, 08 August 2014 14:38] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04379 seconds