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

Bug 346685

Summary: [typeInference] bug when combining alternatives and assigned actions
Product: [Modeling] TMF Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sqctrd
Version: unspecifiedFlags: sebastian.zarnekow: indigo+
Target Milestone: SR2   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Moritz Eysholdt CLA 2011-05-20 10:13:38 EDT
From the grammar

---
TypeA: 'TA' TypeD ({TypeB.x=current} 'x' | {TypeC.x=current} 'y')? name+=STRING;
TypeD: name+=ID;
---

the folowing types are infered:

class TypeA {}
class TypeB extends TypeA { ref x; }
class TypeC extends TypeA { ref x; }
class TypeD extends TypeA { attr name; }

this is wrong, because TypeB and TypeC can also have the attribute 'name'. Therefore, the attribute should have been pulled up to TypeA


When removing the alternative from the grammar
---
TypeA: 'TA' TypeD ({TypeB.x=current} 'x')? name+=STRING;
TypeD: name+=ID;
---
attribute 'name' is member of TypeA, as expected.

This is actually the cause for bug 345521.
Comment 1 Sebastian Zarnekow CLA 2011-05-20 10:19:13 EDT
Ouch.
Comment 2 Kevin Sun CLA 2011-06-07 10:06:52 EDT
for the grammar

----

Model:
A ({Me.a = current} b = B)? c=C? ;

A :
{A} 'a';

B :
{B} 'b';

C :
{C} 'c';

----

the editor will meet an error when the input is like this,

---
a c
---

an exception is thrown.
An internal error occurred during: "XtextReconcilerJob".
java.lang.IllegalArgumentException: A.c does not exist.
Comment 3 Sebastian Zarnekow CLA 2011-08-16 16:56:35 EDT
Pushed to master.
Comment 4 Karsten Thoms CLA 2017-09-19 16:51:53 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:03:10 EDT
Closing all bugs that were set to RESOLVED before Neon.0