Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351330 - [xtend] Xtend compiler generates invalid java code
Summary: [xtend] Xtend compiler generates invalid java code
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-06 09:45 EDT by Bernd Kolb CLA
Modified: 2017-09-19 17:06 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Kolb CLA 2011-07-06 09:45:44 EDT
Build Identifier: 3.7.0 final Eclipse release, xtext distro from itemis

The xtend2 compiler generates invalid java code for the following function:

def toSeparatedString(Iterable<T> i, (T)=>String toStringFunc, String separator){
	i.map(T x | toStringFunc.apply(x)).join(separator)
}


The result looks as follows:

public String toSeparatedString(final Iterable<?> i, final Function1<?,String> toStringFun, final String separator) {
    final Function1<?,String> _function = new Function1<?,String>() {
        public String apply(final ? x) {
          String _apply = toStringFun.apply(x);
          return _apply;
        }
      };
    Iterable<String> _map = IterableExtensions.<?, String>map(i, _function);
    String _join = IterableExtensions.join(_map, separator);
    return _join;
  }


The inner apply Method uses ? as a type

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-07-06 11:45:33 EDT
This is documented in the disabled testcase  org.eclipse.xtext.xtend2.tests.linking.InferredJvmModelTest.testInferredFunctionWithTypeParameter()
Comment 2 Sebastian Zarnekow CLA 2011-07-13 09:41:37 EDT
The code snippet seems to be invalid: T is nowhere defined. 
Bernd, did you declare T as a type parameter for the Xtend class?
Comment 3 Sebastian Zarnekow CLA 2011-07-13 10:00:50 EDT
Added some test cases to document that the generated code is correct as long as T was defined somewhere. Since there are error markers if T was not defined, I close this ticket. Please reopen and provide a complete Xtend file if the problem is still present in the latest nightlies.
Comment 4 Karsten Thoms CLA 2017-09-19 16:55:24 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:06:09 EDT
Closing all bugs that were set to RESOLVED before Neon.0