Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364869 - [xtend] explicit return required in create + dispatch method
Summary: [xtend] explicit return required in create + dispatch method
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.1.0   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-25 14:16 EST by Edwin Park CLA
Modified: 2017-09-19 17:29 EDT (History)
1 user (show)

See Also:
sven.efftinge: juno+


Attachments

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