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

Bug 342173

Summary: [Xtend] Improve return type inference for recursive methods
Product: [Tools] Xtend Reporter: Robert von Massow <rvonmassow>
Component: CoreAssignee: Project Inbox <xtend-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: btickets, dennis.huebner, jan, karsten.thoms, moritz.eysholdt, sebastian.zarnekow, sven.efftinge
Version: 2.2.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 376037    
Bug Blocks:    

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 ***