Warn about unused event handler return values

If an event handler has a non-void return type, a warning is issued as
the event bus cannot use the returned value.

In rare cases this might be justified as the event handler could be
invoked directly.
This commit is contained in:
Kai S. K. Engelbart 2021-02-19 11:34:58 +01:00
parent b56f08e441
commit 8a30493c52
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
1 changed files with 4 additions and 0 deletions

View File

@ -63,6 +63,10 @@ public class EventProcessor extends AbstractProcessor {
else
pass = true;
// Warn the user about unused return values
if (useParameter && eventHandler.getReturnType().getKind() != TypeKind.VOID)
warning(eventHandler, "Unused return value");
// Abort checking if the handler signature is incorrect
if (!pass)
continue;