Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342173 - [Xtend] Improve return type inference for recursive methods
Summary: [Xtend] Improve return type inference for recursive methods
Status: CLOSED DUPLICATE of bug 404817
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 352706 (view as bug list)
Depends on: 376037
Blocks:
  Show dependency tree
 
Reported: 2011-04-07 10:53 EDT by Robert von Massow CLA
Modified: 2013-09-13 05:30 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert von Massow CLA 2011-04-07 10:53:11 EDT
Build Identifier: 201104061304

I have the following Xtend dispatch function:

dispatch labelName(AbstractSection aS){
	aS.eContainer().labelName() + "-"
}

dispatch labelName(Object any){
	""
}

The editor complains here:

Couldn't resolve reference to JvmIdentifiableElement '+'. 

Also the whole function "labelName(AbstractSection aS)" is evaluated to be of type void, which is actually not the case.

Reproducible: Always
Comment 1 Sven Efftinge CLA 2011-04-07 11:00:29 EDT
Because there is a recursion involved, you need to explicitly declare the return type (defaults to Object).
We need to add a validation.
Comment 2 Sebastian Zarnekow CLA 2011-05-04 06:11:38 EDT
Preliminary scheduled for 2.0RC1
Comment 3 Sven Efftinge CLA 2011-05-04 09:59:09 EDT
postponed to SR1
Comment 4 Sebastian Zarnekow CLA 2011-07-21 04:30:47 EDT
*** Bug 352706 has been marked as a duplicate of this bug. ***
Comment 5 Jan Koehnlein CLA 2011-10-14 07:25:55 EDT
If we want to solve this for all cases, this requires a significant amount of static code analysis which is not yet there. Postponed.
Comment 6 Dennis Huebner CLA 2013-02-13 03:43:37 EST
Partially valid.

Actually:
- return type is now Object instead of void
- we have validation (warning message)

Should:
- return type should be String


Example:
	dispatch def labelName(EObject eObj) {// WARNING
		eObj.eContainer.labelName() + "_"
	}
	
	
	dispatch def labelName(Object obj) { //WARNING
		""
	}
	
	def test342173() {
		val eObj = EcoreFactory::eINSTANCE.createEObject
		val String str = eObj.labelName() //ERROR 
	}
Comment 7 Sven Efftinge CLA 2013-09-13 05:30:21 EDT

*** This bug has been marked as a duplicate of bug 404817 ***