Community
Participate
Working Groups
Build Identifier: 20110609-2236 In the grammar of Xbase there is an optional expression after the return keyword: XReturnExpression returns XExpression : {XReturnExpression} 'return' (=>expression=XExpression)?; But in the TypeProvider this is never evaluated: protected JvmTypeReference _type(XReturnExpression object, boolean rawType) { final JvmTypeReference typeForName = getPrimitiveVoid(object); return typeForName; } Better do it like this: protected JvmTypeReference _type( final XReturnExpression object, final boolean rawType ) { final JvmTypeReference typeForName; if (object.getExpression() == null) typeForName = getPrimitiveVoid( object ); else typeForName = getType( object.getExpression() ); return typeForName; } Reproducible: Always
The type of a return expression is always void, e.g you cannot use it in an assignment like this: var x = return 1; The "return type" of a return expression is what you are looking for.
Ah ok, thought this is something for the validation and not for the typesystem... But what do you mean by "The "return type" of a return expression"? Which method of the TypeProvider gives me the "wanted" type?
It's org.eclipse.xtext.xbase.typing.ITypeProvider.getCommonReturnType(XExpression, boolean)
Thanks, that is a nice method. Sorry for the blocker then :(
(In reply to comment #4) > Sorry for the blocker then :( No problem.
Closing all bugs that were set to RESOLVED before Neon.0