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

Bug 364961

Summary: [xtend] member initializer with refs to member vars compile to invalid java code
Product: [Modeling] TMF Reporter: Moritz Eysholdt <moritz.eysholdt>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: sebastian.zarnekow
Version: unspecifiedFlags: moritz.eysholdt: juno+
Target Milestone: M4   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:

Description Moritz Eysholdt CLA 2011-11-28 10:09:47 EST
The snippet

---
class bar {
	int i = 12
	int x = i + 1 
}
---

compiles to 

---
public class bar {
  private int i = 12;
  
  private int x = new Function0<Integer>() {
    public Integer apply() {
      int _operator_plus = IntegerExtensions.operator_plus(((Integer)this.i), ((Integer)1));
      return _operator_plus;
    }
  }.apply();
}
---

which doesn't compile due to the error "i cannot be resolved or is not a field" under "this.i".

I'd expect "bar.this.i" to be generated by the compiler instead of "this.i".
Comment 1 Sebastian Zarnekow CLA 2011-11-28 11:33:45 EST
Pushed to master.
Comment 2 Karsten Thoms CLA 2017-09-19 17:51:00 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 18:01:46 EDT
Closing all bugs that were set to RESOLVED before Neon.0