| Summary: | [xtend] Undetected syntax error leading to uncompilable code | ||
|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Karsten Thoms <karsten.thoms> |
| Component: | Core | Assignee: | Project Inbox <xtend-inbox> |
| Status: | CLOSED WORKSFORME | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sebastian.zarnekow, sven.efftinge |
| Version: | 2.3.0 | Flags: | sven.efftinge:
kepler+
|
| Target Milestone: | M6 | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
| Bug Depends on: | 376037 | ||
| Bug Blocks: | |||
What do you mean by 'implementation of body()'?. Which class are you referring to? Previous versions of the Domainmodel example had a Xtend Rich String based code generator as example (which version was current in April last year?).
I tried to reproduce it with the Fowler example. I get another error when I insert this into StatemachineGenerator.xtend#toJavaCode(Statemachine sm):
«sm.commands.map(c|c.declareCommand).flatten»
Incompatible receiver type. Expected java.lang.Iterable<? extends java.lang.Iterable<? extends T>> or java.lang.Iterable<? extends T>[] but was java.util.List<java.lang.CharSequence>
"declareCommand" infers CharSequence as return type, thus I would expect that "sm.commands.map(c|c.declareCommand)" results into Iterable<CharSequence>, which should be a valid argument for the flatten() method.
(In reply to comment #2) > "declareCommand" infers CharSequence as return type, thus I would expect > that "sm.commands.map(c|c.declareCommand)" results into > Iterable<CharSequence>, which should be a valid argument for the flatten() > method. flatten is defined like this : public static <T> Iterable<T> flatten(Iterable<? extends Iterable<? extends T>> inputs) { So I'd say the error message is correct. Right, did not think about that correctly. So I guess this was not checked properly before and was just compiled, which resulted in the uncompilable code. Thus, I'd consider this as fixed in the meantime. Requested via bug 522520. -M. Requested via bug 522520. -M. |
Steps to reproduce: - Use Domainmodel example - Change implementation of body() to: body(Entity e) { ''' public class «e.name» «e.superTypeClause()»{ «e.features.map(f|f.feature).flatten» } ''' } This will lead to the following code: List<StringConcatenation> _map = ListExtensions.<Feature, StringConcatenation>map(_features, _function); Iterable<?> _flatten = IterableExtensions.flatten(_map); and this syntax error in the Java code: The method flatten(Iterable<? extends Iterable<? extends T>>) in the type IterableExtensions is not applicable for the arguments (List<StringConcatenation>)