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

Bug 355690

Summary: Syntax error in closure
Product: [Modeling] TMF Reporter: Hauke Fuhrmann <haf>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sven.efftinge
Version: unspecifiedFlags: sven.efftinge: indigo+
Target Milestone: SR1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Hauke Fuhrmann CLA 2011-08-24 07:07:22 EDT
Build Identifier: 20110615-0604

This example xtend file generates code where the part 
"public Boolean apply(final ? e)" cannot be comiled:

------------------
import java.util.ArrayList
class Test {
	def <T> ArrayList<T> test(Iterable<T> iterable){
		var list = new ArrayList<T>()
		for(item:iterable){
			if(!list.exists(e|e==item)){
				list.add(item)
			}
		}
		list
	}	
}
------------------
generates to
------------------
import java.util.ArrayList;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;

@SuppressWarnings("all")
public class Test {
  
  public <T> ArrayList<T> test(final Iterable<T> iterable) {
    ArrayList<T> _xblockexpression = null;
    {
      ArrayList<T> _arrayList = new ArrayList<T>();
      ArrayList<T> list = _arrayList;
      for (T item : iterable) {
        final Function1<?,Boolean> _function = new Function1<?,Boolean>() {
            public Boolean apply(final ? e) {
              boolean _operator_equals = ObjectExtensions.operator_equals(e, item);
              return ((Boolean)_operator_equals);
            }
          };
        boolean _exists = IterableExtensions.<?>exists(list, _function);
        boolean _operator_not = BooleanExtensions.operator_not(_exists);
        if (_operator_not) {
          list.add(item);
        }
      }
      _xblockexpression = (list);
    }
    return _xblockexpression;
  }
}

Reproducible: Always
Comment 1 Sven Efftinge CLA 2011-08-24 07:12:48 EDT
this has already been fixed.
Comment 2 Karsten Thoms CLA 2017-09-19 17:08:19 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:19:52 EDT
Closing all bugs that were set to RESOLVED before Neon.0