Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363071 - [xtend2] illegal Java code for create-method with xtend factory method
Summary: [xtend2] illegal Java code for create-method with xtend factory method
Status: CLOSED DUPLICATE of bug 362868
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-07 12:25 EST by Hauke Fuhrmann CLA
Modified: 2011-11-07 12:28 EST (History)
1 user (show)

See Also:
sebastian.zarnekow: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hauke Fuhrmann CLA 2011-11-07 12:25:27 EST
Build Identifier: 20110916-0149

Using an Xtend function as a factory method in a create-function fails with wrong Java code. The class used to call the factory method is not defined.

Xtend:

class Test {
  def create foo:bar.createTest transform(Test bar){
    foo
  }
  def createTest(Test blubb){
    new Test()
  }
}

Java:

@SuppressWarnings("all")
public class Test {
  public Test transform(final Test bar) {
    final ArrayList<?>_cacheKey = CollectionLiterals.newArrayList(bar);
    final Test _result;
    synchronized (_createCache_transform) {
      if (_createCache_transform.containsKey(_cacheKey)) {
        return _createCache_transform.get(_cacheKey);
      }
      Test _Test = Test;  // <== This Test reference is unknown
      Test _createTest = _Test.createTest(bar);
      _result = _createTest;
      _createCache_transform.put(_cacheKey, _result);
    }
    _init_transform(_result, bar);
    return _result;
  }
  
  private final HashMap<ArrayList<?>,Test> _createCache_transform = CollectionLiterals.newHashMap();
  
  private void _init_transform(final Test foo, final Test bar) {
  }
  
  public Test createTest(final Test blubb) {
    Test _test = new Test();
    return _test;
  }
}


Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-11-07 12:27:53 EST

*** This bug has been marked as a duplicate of bug 362868 ***