| Summary: | [xtend] explicit return required in create + dispatch method | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Edwin Park <esp1> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | sven.efftinge |
| Version: | 2.1.0 | Flags: | sven.efftinge:
juno+
|
| Target Milestone: | M4 | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
This has already been fixed with 2.1.0 Perhaps this is a regression then? This is not working for me in Xtext 2.1.1.v201111141332. The posted code does not show errors for you when you comment out the last line of the create method? Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
Build Identifier: 20110916-0149 Create methods are supposed to return the created instance, regardless of the contents of the method body. However, I found that if you have a create method that is also a dispatch method, it requires an explicit return of the created instance. Reproducible: Always Steps to Reproduce: 1. Create the following Xtend class: class Foo { def dispatch Collection foo(List list) { list } def dispatch create new ArrayList() foo(HashMap map) { it.addAll(map.keySet) it // this is required, although it shouldn't be } } 2. Note the explicit 'it' as the last statement in the second dispatch method. According to the documentation for create methods, this shouldn't be necessary. But if you comment this out, you'll get an error 'Incompatible return type of dispatch method'. Note: This is with Xtext 2.1.1