Community
Participate
Working Groups
Build Identifier: Maybe a warning or an error should be issued for the following xtend file: override void doGenerate(Resource resource, IFileSystemAccess fsa) { generate(resource, fsa) "returns a string but void is return type" } generated Java code: public void doGenerate(final Resource resource, final IFileSystemAccess fsa) throws RuntimeException { { this.generate(resource, fsa);/*"returns a string but void is return type"*/; } } expected: no generated Java code with error or a warning message I am using Xtext/Xtend 2.0.1.v201106261503 Reproducible: Always
The Xtend code and the generated Java code looks good to me. Why do you think it should result in a validation error?
I think there is already a warniong for expressions which don't cause any side effects but it is not triggered for the last expression, e.g. def void foo2() { "first" "second" } "first" will be flagged with "The expression does not cause any side effects and therefore doesn't do anything in this context."
Thanks for looking into this. Sven, in my example, the user's last expression returns a string, but he erroneously declared the method to return "void" instead of "String". Sebastian, I agree. I would consider the issue fixed if the warning "The expression does not cause any side effects and therefore doesn't do anything in this context." was also triggered on the last expression.
pushed to master
Requested via bug 522520. -M.