| Summary: | [Xtend] Improve return type inference for recursive methods | ||
|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Robert von Massow <rvonmassow> |
| Component: | Core | Assignee: | 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: | |||
Because there is a recursion involved, you need to explicitly declare the return type (defaults to Object). We need to add a validation. Preliminary scheduled for 2.0RC1 postponed to SR1 *** Bug 352706 has been marked as a duplicate of this bug. *** If we want to solve this for all cases, this requires a significant amount of static code analysis which is not yet there. Postponed. 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
}
*** This bug has been marked as a duplicate of bug 404817 *** |
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