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

Bug 364869

Summary: [xtend] explicit return required in create + dispatch method
Product: [Modeling] TMF Reporter: Edwin Park <esp1>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sven.efftinge
Version: 2.1.0Flags: sven.efftinge: juno+
Target Milestone: M4   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Edwin Park CLA 2011-11-25 14:16:48 EST
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
Comment 1 Sven Efftinge CLA 2011-12-01 05:45:15 EST
This has already been fixed with 2.1.0
Comment 2 Edwin Park CLA 2011-12-01 13:14:19 EST
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?
Comment 3 Karsten Thoms CLA 2017-09-19 17:18:16 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 17:29:37 EDT
Closing all bugs that were set to RESOLVED before Neon.0