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

Bug 360007

Summary: Wrong ecore model inference
Product: [Modeling] TMF Reporter: Mark Christiaens <mark.g.j.christiaens>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: mark.g.j.christiaens, moritz.eysholdt, sebastian.zarnekow
Version: 2.0.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Mark Christiaens CLA 2011-10-05 11:57:51 EDT
Build Identifier: 20110916-0149

The Xtext editor complains about the following grammar having duplicate features (in pretty much every class). 

G1:	B | C;
G2:	C | D;
B:	'b' blub=ID;
C:	'c' blub=ID;
D:	'd' blub=ID;
terminal ID:	('a'..'z')*;

I expect the "blub" feature field to present in G1 and G2 and not conflict. 

Reproducible: Always
Comment 1 Mark Christiaens CLA 2011-10-05 11:59:34 EDT
I'm actually working with something close to the head of the Xtext repo (higher than 2.0.1).
Comment 2 Moritz Eysholdt CLA 2011-10-05 12:05:08 EDT
Since C extends both G1 and G2 I don't see how the conflict can be avoided by the means of ecore inference.

To avoid that C inherits feature "blub" twice, you'd have to introduce a common super type for G1 and G2. This super type would then own "blub".

G1:    B | C;
G2:    C | D;
IsNeverCalled: G1 | G2;
B:    'b' blub=ID;
C:    'c' blub=ID;
D:    'd' blub=ID;
terminal ID:    ('a'..'z')*;
Comment 3 Sebastian Zarnekow CLA 2011-10-05 12:26:11 EDT
This would produce an invalid ecore model, IIRC.
Since C inherits from G1 and G2, it would end up with two features with the same name. Please reopen if the Ecore editor's validate action does not yield an error for such kind of model.
Comment 4 Sebastian Zarnekow CLA 2011-10-05 12:28:50 EDT
Just tried this myself. You'd end up with

There may not be two features named 'blub'	My.ecore	/sample.help/src	Unknown	EMF Problem

for

<eClassifiers xsi:type="ecore:EClass" name="G1">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="G2">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="C" eSuperTypes="#//G1 #//G2"/>
Comment 5 Karsten Thoms CLA 2017-09-19 17:38:45 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 17:49:56 EDT
Closing all bugs that were set to RESOLVED before Neon.0