Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355690 - Syntax error in closure
Summary: Syntax error in closure
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-24 07:07 EDT by Hauke Fuhrmann CLA
Modified: 2017-09-19 17:19 EDT (History)
1 user (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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